DietaryGuard/lib/main.dart

68 lines
1.8 KiB
Dart
Raw Normal View History

2024-08-14 17:26:42 +00:00
import 'package:dietary_guard/controllers/food_data.dart';
2024-08-14 15:43:21 +00:00
import 'package:dietary_guard/screens/query.dart';
import 'package:dietary_guard/screens/settings.dart';
import 'package:dietary_guard/shells/nav_shell.dart';
2024-08-14 17:26:42 +00:00
import 'package:dietary_guard/translations.dart';
2024-08-14 15:43:21 +00:00
import 'package:flutter/material.dart';
import 'package:get/get.dart';
import 'package:go_router/go_router.dart';
void main() {
runApp(const MyApp());
}
final router = GoRouter(routes: [
ShellRoute(
builder: (context, state, child) => NavShell(child: child),
routes: [
GoRoute(
path: "/",
name: "query",
builder: (context, state) => const QueryScreen(),
),
GoRoute(
path: "/settings",
name: "settings",
builder: (context, state) => const SettingsScreen(),
),
],
),
]);
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return GetMaterialApp.router(
title: 'DietaryGuard',
routerDelegate: router.routerDelegate,
routeInformationParser: router.routeInformationParser,
routeInformationProvider: router.routeInformationProvider,
backButtonDispatcher: router.backButtonDispatcher,
locale: Get.deviceLocale,
theme: ThemeData(
colorScheme: ColorScheme.fromSeed(
seedColor: Colors.green,
2024-08-14 17:26:42 +00:00
brightness: Brightness.light,
2024-08-14 15:43:21 +00:00
),
useMaterial3: true,
),
2024-08-14 17:26:42 +00:00
darkTheme: ThemeData(
colorScheme: ColorScheme.fromSeed(
seedColor: Colors.green,
brightness: Brightness.dark,
),
useMaterial3: true,
),
themeMode: ThemeMode.system,
translations: AppTranslations(),
onInit: () => _initializeProviders(context),
2024-08-14 15:43:21 +00:00
);
}
2024-08-14 17:26:42 +00:00
void _initializeProviders(BuildContext context) async {
Get.put(FoodDataController());
}
2024-08-14 15:43:21 +00:00
}