little_strategy/lib/main.dart
2024-11-18 07:44:55 +01:00

49 lines
1.5 KiB
Dart

import 'package:board_game/board_game.dart';
import 'package:flutter/material.dart';
import 'package:key_value_storage/key_value_storage.dart';
import 'package:provider/provider.dart';
import 'package:user_repository/user_repository.dart';
void main() {
runApp(
MultiProvider(
providers: [
// Ton provider UserRepository
Provider(
create: (context) => LocalUserRepository(
keyValueStorage: KeyValueStorage(),
),
),
// Providers pour la gestion de l'état
ChangeNotifierProvider(create: (context) => CellListProvider()),
ChangeNotifierProvider(create: (context) => ArticleListProvider()),
ChangeNotifierProvider(create: (context) => SettingsProvider()),
ChangeNotifierProvider(
create: (context) =>
UserProvider(context.read<LocalUserRepository>()),
),
],
child: const MainApp(), // Maintenant MainApp a accès aux providers
),
);
}
class MainApp extends StatelessWidget {
const MainApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
theme: context.watch<SettingsProvider>().state.theme,
title: 'Little Strategy Game',
routes: {
'/': (context) => const LoginScreen(),
'/lobby': (context) => const Lobby(),
'/settings': (context) => const Settings(),
'/blog': (context) => const Blog(),
},
);
}
}