How to expose dart state class functions so that I can update them via event listeners?

21 Views Asked by At

I have dart class for app's state, I want to be able to set the state of this flutter's app after its built and embedded in a react app.

I have made this app using FlutterFlow and this class is also generated one. I want to modify it to use @JSExport so that I can pass the state object in some event listener as listen it on react side.

import 'package:flutter/material.dart';

class FFAppState extends ChangeNotifier {
  static FFAppState _instance = FFAppState._internal();

  factory FFAppState() {
    return _instance;
  }

  FFAppState._internal();

  static void reset() {
    _instance = FFAppState._internal();
  }

  Future initializePersistedState() async {}

  void update(VoidCallback callback) {
    callback();
    notifyListeners();
  }

  int _counter = 0;
  int get counter => _counter;
  set counter(int value) {
    _counter = value;
  }
}
0

There are 0 best solutions below