MyApp class
Root widget that configures the app's theme and dependency injection.
Sets up a MultiProvider chain that:
- Listens to FirebaseAuth.authStateChanges via
StreamProvider<User?> - Wires User changes into AppState via
ChangeNotifierProxyProvider<User?, AppState> - Configures Material 3 theme with teal color scheme
- Sets up GoRouter for navigation with auth guards
Dependency Injection Structure
The provider hierarchy allows all descendant widgets to access:
Provider Chain Details
StreamProvider
Streams FirebaseAuth user changes to the widget tree. Listens to
FirebaseAuth.instance.authStateChanges() which emits:
- A User object when login succeeds
nullwhen logout occurs- Initial state on app startup
The initialData: null ensures the app shows login screen before
Firebase completes the first auth check.
ChangeNotifierProxyProvider
Syncs User changes into AppState for app-wide state management.
This creates a dependency relationship where AppState depends on
the StreamProvider<User?>.
When User changes:
- AppState.updateUser is called with the new User
- AppState clears or loads data based on login/logout
- All widgets watching AppState rebuild automatically
The create callback initializes AppState once on first build.
The update callback runs whenever User changes.
Theme Configuration
Uses Material 3 design with teal as the primary color seed. The theme is automatically generated from ColorScheme based on the seed color.
Navigation Setup
Uses MaterialApp.router with GoRouter configured in router for:
- Deep linking support
- Auth-based route guards
- Declarative navigation
- Inheritance
Constructors
Properties
Methods
-
build(
BuildContext context) → Widget -
Describes the part of the user interface represented by this widget.
override
-
createElement(
) → StatelessElement -
Creates a StatelessElement to manage this widget's 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
-
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, int wrapWidth = 65}) → 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