flutter_mobx public API
This reference is generated from the resolved exports of package:flutter_mobx/flutter_mobx.dart, including export filters and explicitly declared public members. Inherited Dart and Flutter members follow their platform contracts. Start with the learning path for guided examples, or API families to choose the right abstraction. Low-level exports support adapters and generated code; exporting a symbol does not make it the best starting point for an application.
MultiReactionBuilder
Import: package:flutter_mobx/flutter_mobx.dart
class MultiReactionBuilder extends MultiProvider{@template multi_reaction_builder} Merges multiple [ReactionBuilder] widgets into one widget tree.
[MultiReactionBuilder] improves the readability and eliminates the need to nest multiple [ReactionBuilder]s.
By using [MultiReactionBuilder] we can go from:
ReactionBuilder(
builder: (context) {},
child: ReactionBuilder(
builder: (context) {},
child: ReactionBuilder(
builder: (context) {},
child: ChildA(),
),
),
)to:
MultiReactionBuilder(
builders: [
ReactionBuilder(
builder: (context) {},
),
ReactionBuilder(
builder: (context) {},
),
ReactionBuilder(
builder: (context) {},
),
],
child: ChildA(),
)[MultiReactionBuilder] converts the [ReactionBuilder] list into a tree of nested [ReactionBuilder] widgets. As a result, the only advantage of using [MultiReactionBuilder] is improved readability due to the reduction in nesting and boilerplate.
MultiReactionBuilder
MultiReactionBuilder({Key? key, required List<ReactionBuilder> builders, required Widget child})Observer
Import: package:flutter_mobx/flutter_mobx.dart
class Observer extends StatelessObserverWidgetA [StatelessObserverWidget] that delegate its [build] method to [builder].
See also:
- [Builder], which is the same thing but for [StatelessWidget] instead.
Observer
Observer({Key? key, required Widget Function(BuildContext) builder, String? name, bool? warnWhenNoObservables})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
Observer.withBuiltChild
Observer.withBuiltChild({Key? key, required Widget Function(BuildContext, Widget) builder, required Widget child, String? name, bool? warnWhenNoObservables})Observer which excludes the child branch from being rebuilt
[builder] is a builder function with a child widget as a parameter;
[child] is the widget to pass to the [builder] function.
builder
Widget Function(BuildContext) builderUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
debugConstructingStackFrame
String? debugConstructingStackFrameThe stack frame pointing to the source that constructed this instance.
builder
Widget Function(BuildContext) get builderUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
debugConstructingStackFrame
String? get debugConstructingStackFrameUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
getName
String getName()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
build
Widget build(BuildContext context)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
debugFindConstructingStackFrame
String? debugFindConstructingStackFrame([StackTrace? stackTrace])Finds the first non-constructor frame in the stack trace.
[stackTrace] defaults to [StackTrace.current].
ObserverElementMixin
Import: package:flutter_mobx/flutter_mobx.dart
mixin ObserverElementMixin on ComponentElementA mixin that overrides [build] to listen to the observables used by [ObserverWidgetMixin].
reaction
ReactionImpl reactionUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
reaction
ReactionImpl get reactionUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
mount
void mount(Element? parent, dynamic newSlot)Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
invalidate
void invalidate()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
build
Widget build()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
unmount
void unmount()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
ObserverWidgetMixin
Import: package:flutter_mobx/flutter_mobx.dart
mixin ObserverWidgetMixin on WidgetObserver 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.
Internally, [ObserverWidgetMixin] uses a [Reaction] around the build method.
If your build method does not contain any observables, [ObserverWidgetMixin] will print a warning on the console. This is a debug-time hint to let you know that you are not observing any observables.
warnWhenNoObservables
bool? warnWhenNoObservablesUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
warnWhenNoObservables
bool? get warnWhenNoObservablesWhether to warn when there is no observables in the builder function null means true
getName
String getName()An identifiable name that can be overriden for debugging.
getContext
ReactiveContext getContext()The context within which its reaction should be run. It is the [mainContext] in most cases.
createReaction
Reaction createReaction(dynamic Function() onInvalidate, {dynamic Function(Object, Reaction)? onError})A convenience method used for testing.
log
void log(String msg)Convenience method to output console messages as debugging output. Logging usually happens when some internal error needs to be surfaced to the user.
ReactionBuilder
Import: package:flutter_mobx/flutter_mobx.dart
class ReactionBuilder extends SingleChildStatefulWidgetReactionBuilder is useful for triggering reactions via a builder function rather than creating a custom StatefulWidget for handling the same. Without a [ReactionBuilder] you would normally have to create a StatefulWidget where the initState() would be used to setup the reaction and then dispose it off in the dispose() method.
Although simple, this little helper Widget eliminates the need to create such a widget and handles the lifetime of the reaction correctly. To use it, pass a [builder] that takes in a [BuildContext] and prepares the reaction. It should end up returning a [ReactionDisposer]. This will be disposed when the [ReactionBuilder] is disposed. The [child] Widget gets rendered as part of the build process.
ReactionBuilder
ReactionBuilder({Key? key, Widget? child, required ReactionDisposer Function(BuildContext) builder})Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
builder
ReactionDisposer Function(BuildContext) builderUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
builder
ReactionDisposer Function(BuildContext) get builderUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
createState
ReactionBuilderState createState()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
ReactionBuilderFunction
Import: package:flutter_mobx/flutter_mobx.dart
typedef ReactionBuilderFunction = ReactionDisposer Function(BuildContext)A builder function that creates a reaction
StatefulObserverElement
Import: package:flutter_mobx/flutter_mobx.dart
class StatefulObserverElement extends StatefulElement with ObserverElementMixinAn [Element] that uses a [StatefulObserverWidget] as its configuration.
StatefulObserverElement
StatefulObserverElement(StatefulObserverWidget widget)Creates an element that uses the given widget as its configuration.
widget
StatefulObserverWidget widgetUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
widget
StatefulObserverWidget get widgetUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
StatefulObserverWidget
Import: package:flutter_mobx/flutter_mobx.dart
abstract class StatefulObserverWidget extends StatefulWidget with ObserverWidgetMixinA [StatefulWidget] that rebuilds when an [Observable] used inside [State.build] updates.
See also:
- [Observer], which subclass this interface and delegate its
buildto a callback. - [StatelessObserverWidget], similar to this class, but with no [State].
StatefulObserverWidget
StatefulObserverWidget({Key? key, ReactiveContext? context, String? name})Initializes [key], [context] and [name] for subclasses.
getName
String getName()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
getContext
ReactiveContext getContext()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
createElement
StatefulObserverElement createElement()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
StatelessObserverElement
Import: package:flutter_mobx/flutter_mobx.dart
class StatelessObserverElement extends StatelessElement with ObserverElementMixinAn [Element] that uses a [StatelessObserverWidget] as its configuration.
StatelessObserverElement
StatelessObserverElement(StatelessObserverWidget widget)Creates an element that uses the given widget as its configuration.
widget
StatelessObserverWidget widgetUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
widget
StatelessObserverWidget get widgetUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
StatelessObserverWidget
Import: package:flutter_mobx/flutter_mobx.dart
abstract class StatelessObserverWidget extends StatelessWidget with ObserverWidgetMixinA [StatelessWidget] that rebuilds when an [Observable] used inside [build] updates.
See also:
- [Observer], which subclass this interface and delegate its [build] to a callback.
- [StatefulObserverWidget], similar to this class, but that has a [State].
StatelessObserverWidget
StatelessObserverWidget({Key? key, ReactiveContext? context, String? name, bool? warnWhenNoObservables})Initializes [key], [context] and [name] for subclasses.
warnWhenNoObservables
bool? warnWhenNoObservablesUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
warnWhenNoObservables
bool? get warnWhenNoObservablesUses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
getName
String getName()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
getContext
ReactiveContext getContext()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
createElement
StatelessObserverElement createElement()Uses the enclosing type’s contract. Constructor parameters configure this instance; accessors expose its current state. For standard collection or widget overrides, the corresponding Dart or Flutter contract also applies.
debugAddStackTraceInObserverName
Import: package:flutter_mobx/flutter_mobx.dart
bool get debugAddStackTraceInObserverNameSee the API families guide for usage and ownership. This declaration is part of the public export surface.
debugAddStackTraceInObserverName setter
Import: package:flutter_mobx/flutter_mobx.dart
set debugAddStackTraceInObserverName(bool value)See the API families guide for usage and ownership. This declaration is part of the public export surface.
enableWarnWhenNoObservables
Import: package:flutter_mobx/flutter_mobx.dart
bool get enableWarnWhenNoObservablesSee the API families guide for usage and ownership. This declaration is part of the public export surface.
enableWarnWhenNoObservables setter
Import: package:flutter_mobx/flutter_mobx.dart
set enableWarnWhenNoObservables(bool value)See the API families guide for usage and ownership. This declaration is part of the public export surface.
version
Import: package:flutter_mobx/flutter_mobx.dart
String get versionSee the API families guide for usage and ownership. This declaration is part of the public export surface.