tree: 2fc687053c00ca13257fcc525d8a9c3f3d552394 [path history] [tgz]
  1. example/
  2. lib/
  3. analysis_options.yaml
  4. BUILD.gn
  5. build.yaml
  6. CHANGELOG.md
  7. LICENSE
  8. mobx_codegen.iml
  9. pubspec.yaml
  10. README.md
mobx_codegen/README.md

mobx_codegen

pub package Build Status Coverage Status

MobX Code Generation library

Adds support for annotating your MobX code with @observable, @computed, @action, making it super simple to use MobX.

Note that these annotations only work inside store-classes.

store-classes are abstract and use the Store mixin. When you run the build_runner, it will automatically generate the *.g.dart file that must be imported in your file.

$> cd $YOUR_PROJECT_DIR
$> flutter packages pub run build_runner build

Example

import 'package:mobx/mobx.dart';

// Include generated file
part 'todos.g.dart';

// This is the class used by rest of your codebase
class Todo = TodoBase with _$Todo;

// The store-class
abstract class TodoBase with Store {
  TodoBase(this.description);

  @observable
  String description = '';

  @observable
  bool done = false;
}