2023-05-30 09:38:54 +02:00
|
|
|
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;
|
2023-05-30 09:38:54 +02:00
|
|
|
import 'android/config/setup_todaybox_config.dart';
|
|
|
|
|
2023-06-01 12:14:23 +02:00
|
|
|
|
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
|
|
|
|
|
|
|
|
2023-06-01 12:14:23 +02:00
|
|
|
await Hive.openBox(dotenv.env['STATISTICS_TODAY_BOX'] ?? 'STATISTICS_TODAY_BOX');
|
|
|
|
await Hive.openBox( dotenv.env['STATISTICS_PROGRESS_BOX'] ?? 'STATISTICS_PROGRESS_BOX');
|
|
|
|
await Hive.openBox(dotenv.env['STATISTICS_MAIN_BOX'] ?? 'STATISTICS_MAIN_BOX');
|
|
|
|
await Hive.openBox(dotenv.env['MEALPLAN_BOX'] ?? 'MEALPLAN');
|
2023-05-31 23:22:38 +02:00
|
|
|
await Hive.openBox<User>('USER_BOX');
|
2023-06-01 13:19:55 +02:00
|
|
|
//Hive.deleteFromDisk();
|
2023-05-30 09:38:54 +02:00
|
|
|
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
|
|
|
}
|