MyApp class

Root widget that configures the app's theme and dependency injection.

Sets up a MultiProvider chain that:

  1. Listens to FirebaseAuth.authStateChanges via StreamProvider<User?>
  2. Wires User changes into AppState via ChangeNotifierProxyProvider<User?, AppState>
  3. Configures Material 3 theme with teal color scheme
  4. Sets up GoRouter for navigation with auth guards

Dependency Injection Structure

The provider hierarchy allows all descendant widgets to access:

  • Current User via context.watch<User?>()
  • AppState via context.watch<AppState>()

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
  • null when 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:

  1. AppState.updateUser is called with the new User
  2. AppState clears or loads data based on login/logout
  3. 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.

Uses MaterialApp.router with GoRouter configured in router for:

  • Deep linking support
  • Auth-based route guards
  • Declarative navigation
Inheritance

Constructors

MyApp.new({Key? key})
const

Properties

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
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