flutter_mobx 0.3.0

  • README.md
  • Example
  • Installing
  • Versions
  • 96

flutter_mobx #

pub package CircleCI

Flutter integration with MobX.dart.

Provides the Observer widget that listens to observables and automatically rebuilds on changes.

Example #

class CounterExample extends StatefulWidget {
  const CounterExample({Key key}) : super(key: key);

  _CounterExampleState createState() => _CounterExampleState();

class _CounterExampleState extends State<CounterExample> {
  final _counter = Counter();

  Widget build(BuildContext context) => Scaffold(
        appBar: AppBar(
          title: const Text('Counter'),
        body: Center(
          child: Column(
            mainAxisAlignment: MainAxisAlignment.center,
            children: <Widget>[
              const Text(
                'You have pushed the button this many times:',
                  builder: (_) => Text(
                        style: const TextStyle(fontSize: 20),
        floatingActionButton: FloatingActionButton(
          onPressed: _counter.increment,
          tooltip: 'Increment',
          child: const Icon(Icons.add),

Notice the use of the Observer widget that listens to _counter.value, an observable, and rebuilds on changes.

You can go here for more examples

Observer #

Observer(Widget Function(BuildContext context) builder)

The builder function will be monitored by MobX and tracks all the observables that are being used inside it. When any of the observables change, builder will be called again to rebuild the Widget. This gives you a seamless way to create a reactive Widget.

Note that the Observer will also throw an AssertionError if no observables are discovered in the builder function.

Changelog #

0.3.0 #

  • Adapting to the API changes in mobx 0.3.0

0.2.3+1 #

  • Observer is relaying the exception caught during the tracking phase. This is done using the errorValue field present on the reaction instance.

0.2.2 #

  • CHANGELOG updates which got missed out in previous versions
  • The Observer does not trap exceptions occurring during the build() anymore. Previously, this used to be the case, which made it difficult to get proper stack traces.

0.2.1+1 #

  • README updates

0.2.1 #

  • Upgrading to use the 0.2.1 version of mobx, which makes it compatible with the latest beta/dev/master channels

0.2.0 #

  • Upgrading to use the 0.2.0 version of mobx

0.0.2 - 0.1.3 #

  • Warn when no observables are found in the Observer's builder function. This was originally an AssertionError, which was deemed to be too strong and caused apps to crash in debug mode.
  • Updates to tests
  • Updates to documentation

0.0.1 - First release. #

  • Observer component that re-renders when reactive variables change.


Examples #

Counter #

The default example that you get when you create a new Flutter app. Now flavored with MobX :-).

Jump to Source

Todos #

Can't miss out on the Todos! It's a classic way of showcasing a framework.

Jump to Source

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  flutter_mobx: ^0.3.0

2. Install it

You can install packages from the command line:

with Flutter:

$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:flutter_mobx/flutter_mobx.dart';
Version Uploaded Documentation Archive
0.3.0 Jun 23, 2019 Go to the documentation of flutter_mobx 0.3.0 Download flutter_mobx 0.3.0 archive
0.2.3+1 Jun 18, 2019 Go to the documentation of flutter_mobx 0.2.3+1 Download flutter_mobx 0.2.3+1 archive
0.2.3 Jun 18, 2019 Go to the documentation of flutter_mobx 0.2.3 Download flutter_mobx 0.2.3 archive
0.2.2 Jun 15, 2019 Go to the documentation of flutter_mobx 0.2.2 Download flutter_mobx 0.2.2 archive
0.2.1+2 Jun 10, 2019 Go to the documentation of flutter_mobx 0.2.1+2 Download flutter_mobx 0.2.1+2 archive
0.2.1+1 Jun 7, 2019 Go to the documentation of flutter_mobx 0.2.1+1 Download flutter_mobx 0.2.1+1 archive
0.2.1 Jun 7, 2019 Go to the documentation of flutter_mobx 0.2.1 Download flutter_mobx 0.2.1 archive
0.2.0+1 May 24, 2019 Go to the documentation of flutter_mobx 0.2.0+1 Download flutter_mobx 0.2.0+1 archive
0.2.0 May 24, 2019 Go to the documentation of flutter_mobx 0.2.0 Download flutter_mobx 0.2.0 archive
0.1.3 May 9, 2019 Go to the documentation of flutter_mobx 0.1.3 Download flutter_mobx 0.1.3 archive

All 29 versions...

Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Jun 25, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.3.2
  • pana: 0.12.18
  • Flutter: 1.5.4-hotfix.2


Detected platforms: Flutter

References Flutter, and has no conflicting libraries.

Maintenance issues and suggestions

Support latest dependencies. (-5 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.2.0 <3.0.0
flutter 0.0.0
mobx ^0.3.0 0.3.2+2
Transitive dependencies
collection 1.14.11
meta 1.1.6 1.1.7
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
mockito ^4.0.0