mirror of
https://github.com/kuhyx/diet-guard.git
synced 2026-11-19 16:14:32 +01:00
Flutter 3.50 deprecates package:flutter/material.dart; 73 deprecation infos failed flutter analyze --fatal-infos, and four Dart pins were behind (crdt_sync_flutter 0.8.2, flutter_local_notifications 23.0.2, github_device_auth 0.5.0, sync_settings_ui 0.8.2). Those UI packages now sit on material_ui, so the app has to as well or their widgets lose MaterialLocalizations. Imports swap one-for-one and dart fix re-sorted the directives; no behaviour change. analyze is clean and all six test shards pass. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WzxdWWfb63jncj9Lca2jeX
71 lines
2.8 KiB
Dart
71 lines
2.8 KiB
Dart
/// App entry point: initializes local storage services, registers the
|
|
/// background due-slot check, then shows the primary meal-logging screen.
|
|
library;
|
|
|
|
import 'dart:async';
|
|
import 'package:diet_guard_app/screens/log_meal_screen.dart';
|
|
import 'package:diet_guard_app/services/app_settings_service.dart';
|
|
import 'package:diet_guard_app/services/background_tasks.dart';
|
|
import 'package:diet_guard_app/services/body_service.dart';
|
|
import 'package:diet_guard_app/services/budget_history_service.dart';
|
|
import 'package:diet_guard_app/services/foodbank_service.dart';
|
|
import 'package:diet_guard_app/services/frame_stats.dart';
|
|
import 'package:diet_guard_app/services/kuchnia_credential_service.dart';
|
|
import 'package:diet_guard_app/services/kuchnia_queue.dart';
|
|
import 'package:diet_guard_app/services/log_storage_service.dart';
|
|
import 'package:diet_guard_app/services/meal_schedule_service.dart';
|
|
import 'package:diet_guard_app/services/notification_service.dart';
|
|
import 'package:diet_guard_app/services/sync_device_id.dart';
|
|
import 'package:diet_guard_app/ui/theme.dart';
|
|
import 'package:material_ui/material_ui.dart';
|
|
|
|
Future<void> main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
// Before anything that stamps an Hlc or syncs: until this resolves, the
|
|
// device id falls back to the pre-migration role constant.
|
|
await initSyncDeviceId();
|
|
await LogStorageService.init();
|
|
await AppSettingsService.init();
|
|
await BudgetHistoryService.init();
|
|
await MealScheduleService.init();
|
|
await FoodBankService.init();
|
|
await KuchniaCredentialService.init();
|
|
await BodyService.init();
|
|
await KuchniaQueueService.init();
|
|
final notifications = await NotificationService.init();
|
|
// Deliberately *not* awaited before the first frame: the browser's
|
|
// `Notification.requestPermission()` does not complete until the user
|
|
// answers the prompt, so awaiting it here left the desktop app as a blank
|
|
// white window behind the permission bubble. Scheduling is likewise
|
|
// platform-specific (WorkManager on Android, an in-page timer in the
|
|
// browser -- see background_tasks.dart) and equally not worth a delayed
|
|
// first frame.
|
|
// coverage:ignore-start
|
|
unawaited(
|
|
notifications.requestPermission().then((_) {
|
|
return initBackgroundTasks();
|
|
}),
|
|
);
|
|
// coverage:ignore-end
|
|
// Off unless armed with --dart-define=DIET_GUARD_FRAME_STATS=1.
|
|
// coverage:ignore-start
|
|
if (frameStatsEnabled) startFrameStats();
|
|
// coverage:ignore-end
|
|
runApp(const DietGuardApp());
|
|
}
|
|
|
|
/// Root widget for the Diet Guard companion app.
|
|
class DietGuardApp extends StatelessWidget {
|
|
/// Creates the [DietGuardApp] root widget.
|
|
const DietGuardApp({super.key});
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return MaterialApp(
|
|
title: 'Diet Guard',
|
|
theme: buildAppTheme(),
|
|
home: const LogMealScreen(),
|
|
);
|
|
}
|
|
}
|