main function

Future<void> main()

Main entry point for the WIC Shopping Assistant application.

Initializes Firebase and sets up the app's dependency injection layer using MultiProvider from the provider package. This ensures:

  • Real-time FirebaseAuth state changes are available to all widgets
  • AppState is created once and persists across the widget tree
  • User authentication changes automatically sync AppState

The app uses MaterialApp.router with GoRouter for navigation, with auth guards configured in router.

Steps performed:

  1. Ensures Flutter engine is fully initialized via WidgetsFlutterBinding.ensureInitialized
  2. Initializes Firebase with platform-specific options from DefaultFirebaseOptions
  3. Starts the Flutter app with MyApp as the root widget

Side effects:

  • Connects to Firebase project (Auth, Firestore)
  • Enables platform-specific features (camera, storage)
  • Configures dependency injection for the entire app

Implementation

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await Firebase.initializeApp(options: DefaultFirebaseOptions.currentPlatform);
  runApp(const MyApp());
}