build method

  1. @override
Widget build(
  1. BuildContext context
)
override

Builds the app's widget tree.

Wraps the app in a MultiProvider to provide AuthService and ProductRepository, and sets up the MaterialApp with the Wrapper as the home screen and defined routes.

Parameters:

Returns: A Widget representing the app's UI.

Implementation

@override
Widget build(BuildContext context) {
  return MultiProvider(
    providers: [
      Provider<AuthService>(
        create: (_) => AuthService(),
      ),
      Provider<ProductRepository>(
        create: (_) => ProductRepository(),
      ),
    ],
    child: MaterialApp(
      home: const Wrapper(),
      routes: {
        '/farmer': (context) => const FarmerHomeScreen(),
        '/consumer': (context) => const ConsumerHomeScreen(),
        '/farmer_orders': (context) =>
            const FarmerHomeScreen(initialIndex: 1), // Orders tab
        '/consumer_orders': (context) =>
            const ConsumerHomeScreen(initialIndex: 2), //
      },
    ),
  );
}