AppScoped class

Place it close to the route (e.g., on top of MaterialApp) to use state management in the app.

Pass the globally defined AppRef in appRef and the child widget in child.

アプリ内で状態管理を利用するためにルートに近い場所(MaterialAppの上など)に置いてください。

appRefにグローバルに定義したAppRefchildに子供のウィジェットを渡してください。

final appRef = AppRef();

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp();

  @override
  Widget build(BuildContext context){
    return AppScoped(
      appRef: appRef,
      child: MaterialApp(
        ~~~~~
      ),
    );
  }
}
Inheritance
Available Extensions
Annotations

Constructors

AppScoped({Key? key, required AppRef appRef, required Widget child})
Place it close to the route (e.g., on top of MaterialApp) to use state management in the app.
const

Properties

appRef AppRef
Reference for managing the state of the app scope.
final
child Widget
Widgets to be placed below, such as MaterialApp.
final
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() State<StatefulWidget>
Creates the mutable state for this widget at a given location in the tree.
override
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

of(BuildContext context) AppRef?
By passing context, the AppRef set in AppScoped can be obtained.