You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.5 KiB
50 lines
1.5 KiB
import 'package:flutter/material.dart';
|
|
import 'package:get/get.dart';
|
|
//import 'package:youmazgestion/Services/app_database.dart';
|
|
import 'package:youmazgestion/Services/stock_managementDatabase.dart';
|
|
import 'package:youmazgestion/controller/userController.dart';
|
|
//import 'Services/productDatabase.dart';
|
|
import 'my_app.dart';
|
|
import 'package:logging/logging.dart';
|
|
|
|
void main() async {
|
|
WidgetsFlutterBinding.ensureInitialized();
|
|
|
|
try {
|
|
// Initialiser les bases de données une seule fois
|
|
// await AppDatabase.instance.deleteDatabaseFile();
|
|
// await ProductDatabase.instance.deleteDatabaseFile();
|
|
|
|
// await ProductDatabase.instance.initDatabase();
|
|
await AppDatabase.instance.initDatabase();
|
|
|
|
|
|
// Afficher les informations de la base (pour debug)
|
|
// await AppDatabase.instance.printDatabaseInfo();
|
|
Get.put(
|
|
UserController()); // Ajoute ce code AVANT tout accès au UserController
|
|
setupLogger();
|
|
|
|
runApp(const GetMaterialApp(
|
|
debugShowCheckedModeBanner: false,
|
|
home: MyApp(),
|
|
));
|
|
} catch (e) {
|
|
print('Erreur lors de l\'initialisation: $e');
|
|
// Vous pourriez vouloir afficher une page d'erreur ici
|
|
runApp(MaterialApp(
|
|
home: Scaffold(
|
|
body: Center(
|
|
child: Text('Erreur d\'initialisation: $e'),
|
|
),
|
|
),
|
|
));
|
|
}
|
|
}
|
|
|
|
void setupLogger() {
|
|
Logger.root.level = Level.ALL;
|
|
Logger.root.onRecord.listen((record) {
|
|
print('${record.level.name}: ${record.time}: ${record.message}');
|
|
});
|
|
}
|
|
|