flutter_mobx library

Provides bindings for using MobX observables with Flutter. The primary way of consuming the observables in Flutter is via the Observer widget.

The example below shows the use of an Observer that has a builder function that consumes the counter.value observable.

  Widget build(BuildContext context) => Scaffold(
       appBar: AppBar(
         backgroundColor: Colors.blue,
         title: const Text('MobX Counter'),
       ),
       body: Center(
         child: Column(
           mainAxisAlignment: MainAxisAlignment.center,
           children: <Widget>[
             const Text(
               'You have pushed the button this many times:',
             ),
             Observer(
                 builder: (_) => Text(
                       '${counter.value}',
                       style: const TextStyle(fontSize: 40),
                     )),
           ],
         ),
       ),
       floatingActionButton: FloatingActionButton(
         onPressed: counter.increment,
         tooltip: 'Increment',
         child: const Icon(Icons.add),
       ),
     );

Classes

Observer
A StatelessObserverWidget that delegate its build method to builder. [...]
StatefulObserverElement
An Element that uses a StatefulObserverWidget as its configuration.
StatefulObserverWidget
A StatefulWidget that rebuilds when an Observable used inside State.build updates. [...]
StatelessObserverElement
An Element that uses a StatelessObserverWidget as its configuration.
StatelessObserverWidget
A StatelessWidget that rebuilds when an Observable used inside build updates. [...]

Mixins

ObserverElementMixin
A mixin that overrides build to listen to the observables used by ObserverWidgetMixin.
ObserverWidgetMixin
Observer observes the observables used in the build method and rebuilds the Widget whenever any of them change. There is no need to do any other wiring besides simply referencing the required observables. [...]

Constants

version → const String
The version as per pubspec.yaml
'1.1.0+1'

Properties

debugAddStackTraceInObserverName bool
true if a stack frame indicating where an Observer was created should be included in its name. This is useful during debugging to identify the source of warnings or errors. [...]
read / write