TopAppWidget class

Prefer using TopStatelessWidget instead.

Widget to put on top of the app.

It disposes all non auto disposed injected model when the app closes.

Useful also to dispose resources and reset injected states for test.

It is also use to provide and listen to InjectedTheme, InjectedI18N

It can also be used to display a splash screen while initialization plugins.

Example of TopAppWidget used to provide InjectedTheme and InjectedI18N

Provide and listen to the InjectedTheme.

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

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return TopAppWidget(//Use TopAppWidget
      injectedTheme: themeRM, //Set the injectedTheme
      injectedI18N: i18nRM, //Set the injectedI18N
      builder: (context) {
        return MaterialApp(
          //
          theme: themeRM.activeTheme(),
          //
          locale: i18nRM.locale,
          localeResolutionCallback: i18nRM.localeResolutionCallback,
          localizationsDelegates: i18n.localizationsDelegates,,
          home: HomePage(),
        );
      },
    );
  }
}
Inheritance

Constructors

TopAppWidget({Key? key, dynamic didChangeAppLifecycleState(AppLifecycleState)?, Widget onWaiting()?, List<Future> ensureInitialization()?, Widget onError(dynamic error, void refresh())?, required Widget builder(BuildContext)})
Widget to put on top of the app.
const

Properties

builder Widget Function(BuildContext)
Child widget to render
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

build(BuildContext context) Widget
Build the widget
override
createElement() StatefulElement
Creates a StatefulElement to manage this widget's location in the tree.
inherited
createState() → _TopStatelessWidgetState
Creates the mutable state for this widget at a given location in the tree.
inherited
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
didChangeAppLifecycleState(AppLifecycleState state) → void
Called when the system puts the app in the background or returns the app to the foreground.
override
didMountWidget() → void
Called when the widget is first inserted in the widget tree
inherited
didUnmountWidget() → void
Called when the widget is removed from the widget tree
inherited
ensureInitialization() List<Future>?
List of future (plugins initialization) to wait for, and display a waiting screen while waiting
override
errorScreen(dynamic error, void refresh()) Widget?
Hook to be called if initialization fails.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
splashScreen() Widget?
Hook to be called while waiting for plugins initialization.
override
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