Flutter-Ernaehrungsapp/lib/main.dart

36 lines
1.0 KiB
Dart
Raw Permalink Normal View History

import 'package:ernaehrung/android/models/food.dart';
2023-05-31 23:22:38 +02:00
import 'package:ernaehrung/android/models/user.dart';
2023-05-29 12:08:46 +02:00
import 'package:ernaehrung/web/web_app.dart';
import 'package:flutter/material.dart';
import 'package:hive_flutter/hive_flutter.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
import 'android/andoird_app.dart';
import 'package:flutter/foundation.dart' show defaultTargetPlatform, kIsWeb;
import 'android/config/setup_todaybox_config.dart';
2023-05-29 12:08:46 +02:00
void main() async {
await dotenv.load(fileName: ".env");
await Hive.initFlutter();
2023-05-31 23:22:38 +02:00
if (!Hive.isAdapterRegistered(0)) {
2023-05-29 12:08:46 +02:00
Hive.registerAdapter(FoodAdapter());
}
2023-05-31 23:22:38 +02:00
if (!Hive.isAdapterRegistered(1)) {
Hive.registerAdapter(UserAdapter());
}
2023-05-29 12:08:46 +02:00
await Hive.openBox('STATISTICS_REDUCED');
await Hive.openBox('STATISTICS_MAIN');
await Hive.openBox('TODAY');
2023-05-31 23:22:38 +02:00
await Hive.openBox<User>('USER_BOX');
setupTodayBox();
2023-05-29 12:08:46 +02:00
2023-05-31 23:22:38 +02:00
if (defaultTargetPlatform == TargetPlatform.android) {
2023-05-29 12:08:46 +02:00
runApp(const AndroidApp());
2023-05-31 23:22:38 +02:00
} else if (kIsWeb) {
2023-05-29 12:08:46 +02:00
runApp(const WebApp());
}
2023-05-31 23:22:38 +02:00
}