DietaryGuard/lib/main.dart

82 lines
2.4 KiB
Dart

import 'package:dietary_guard/controllers/alert.dart';
import 'package:dietary_guard/controllers/food_data.dart';
import 'package:dietary_guard/screens/query.dart';
import 'package:dietary_guard/screens/settings.dart';
import 'package:dietary_guard/screens/settings/alert.dart';
import 'package:dietary_guard/screens/settings/data_source.dart';
import 'package:dietary_guard/shells/nav_shell.dart';
import 'package:dietary_guard/translations.dart';
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(),
),
GoRoute(
path: "/settings/alerts",
name: "settingsAlert",
builder: (context, state) => const AlertSettingsScreen(),
),
GoRoute(
path: "/settings/data-source",
name: "settingsDataSource",
builder: (context, state) => const DataSourceSettingsScreen(),
),
],
),
]);
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,
brightness: Brightness.light,
),
useMaterial3: true,
),
darkTheme: ThemeData(
colorScheme: ColorScheme.fromSeed(
seedColor: Colors.green,
brightness: Brightness.dark,
),
useMaterial3: true,
),
themeMode: ThemeMode.system,
translations: AppTranslations(),
onInit: () => _initializeProviders(context),
);
}
void _initializeProviders(BuildContext context) async {
Get.put(FoodDataController());
Get.put(AlertController());
}
}