Open Kings-k opened 6 months ago
import 'package:ceroapp/Screens/Depositcategories/controlleur/CategoriesProvider.dart'; import 'package:ceroapp/Screens/Depositcategories/model/categorieModel.dart'; import 'package:ceroapp/Screens/articles/controlleur/article_provider.dart'; import 'package:ceroapp/Screens/articles/model/article_model.dart'; import 'package:ceroapp/Screens/deposit/Model/depositMode.dart'; import 'package:ceroapp/Screens/deposit/controlleur/depositProvider.dart'; import 'package:ceroapp/Screens/entreprises/model/entreprise_model.dart'; import 'package:ceroapp/Screens/login/controlleur/login.provider.dart'; import 'package:ceroapp/Screens/prices/controlleur/price_provider.dart'; import 'package:ceroapp/Screens/prices/model/prices_model.dart'; import 'package:ceroapp/Screens/splash/splah_loading.dart'; import 'package:ceroapp/Screens/users/controlleur/user_provider.dart'; import 'package:ceroapp/Screens/users/model/user_model.dart'; import 'package:ceroapp/ressources/publicControlleurs/Api_provider.dart'; import 'package:flutter/material.dart'; import 'package:hive_flutter/adapters.dart'; import 'package:provider/provider.dart'; import 'package:shared_preferences/shared_preferences.dart';
final keyEncriptDataHive = Hive.generateSecureKey(); BoxCollection? collection; SharedPreferences? prefs; GlobalKey navigatorKey = GlobalKey();
void main() async { WidgetsFlutterBinding.ensureInitialized(); prefs = await SharedPreferences.getInstance();
await Hive.initFlutter(); WidgetsBinding.instance.addPostFrameCallback( (timeStamp) async { try { Hive.registerAdapter(ArticleAdapter()); Hive.registerAdapter(depositAdapter()); Hive.registerAdapter(CategoriesModelAdapter()); Hive.registerAdapter(EntrpriseModeAdapter()); Hive.registerAdapter(pricesModelAdapter()); Hive.registerAdapter(userModelAdapter()); await Hive.openBox( 'services_controllers', crashRecovery: true, collection: "ceroDb", // encryptionCipher: HiveAesCipher(keyEncriptDataHive), ); await Hive.openBox( 'deposits_users', crashRecovery: true, collection: "ceroDb", // encryptionCipher: HiveAesCipher(keyEncriptDataHive), ); await Hive.openBox( 'deposits_categories', crashRecovery: true, collection: "ceroDb", // encryptionCipher: HiveAesCipher(keyEncriptDataHive), ); await Hive.openBox( 'enterprises', crashRecovery: true, collection: "ceroDb", // encryptionCipher: HiveAesCipher(keyEncriptDataHive), ); await Hive.openBox( 'prices_categories', crashRecovery: true, collection: "ceroDb", // encryptionCipher: HiveAesCipher(keyEncriptDataHive), ); await Hive.openBox( 'user', crashRecovery: true, collection: "ceroDb", // encryptionCipher: HiveAesCipher(keyEncriptDataHive), ); } catch (e) { print("error while initializing hive ====> ${e.toString()}"); } // final appDocumentDirectory = await getApplicationDocumentsDirectory(); // try { // // Hive.initFlutter(); // Hive.initFlutter(appDocumentDirectory.path); // collection = await BoxCollection.open( // 'db_cero', // { // 'user', // 'enterprises', // 'accounts', // 'affectation_users', // 'attemptactivationaccounts', // 'bonuses', // 'categories_customer_controllers', // 'categories_services_controllers', // 'cautions', // 'colors', // 'comments', // 'customer_controllers', // 'debts', // 'debt_payments', // 'decision_chiefdepartments', // 'decision_decisionteams', // 'decision_teams', // 'defects', // 'departments', // 'deposits_categories', // 'deposits_users', // 'deposit_controllers', // 'deposit_services', // 'details_invoices_statuses', // 'details_requests', // 'document_types', // 'expenditures', // 'expenditures_limits', // 'failed_jobs', // 'fences', // 'fence_ticketings', // 'funds', // 'images', // 'invoices', // 'invoicesdetailscolors', // 'invoicesdetailsdefects', // 'invoicesdetailsmaterials', // 'invoicesdetailsreasons', // 'invoicesdetails_spots', // 'invoicesdetails_styles', // 'invoices_statuses', // 'invoice_details', // 'materials', // 'moneys', // 'money_conversions', // 'nbrdecisionteam_validations', // 'orders', // 'other_entries', // 'owners', // 'password_resets', // 'paymentmodes', // 'personal_access_tokens', // 'points', // 'point_of_sales', // 'posdeposits', // 'pressing_stock_stories', // 'prices_categories', // 'provider_controllers', // 'reasons', // 'requestapprovments', // 'requests', // 'request_files', // 'request_histories', // 'request_references', // 'request_serveds', // 'roles', // 'safeguards', // 'self_references', // 'servants', // 'servicesadditionalfees', // 'services_controllers', // 'spots', // 'statuses', // 'stock_history_controllers', // 'styles', // 'systeminfos', // 'testmodesls', // 'ticket_offices', // 'unit_of_measure_controllers', // 'tables', // 'usersenterprises', // 'users_expenditures_limits', // 'users_point_of_sales', // 'users_ticket_offices', // 'validatedbydecisionteams' // }, // // path: await getApplicationDocumentsDirectory() , // path: appDocumentDirectory.path, // key: HiveAesCipher(keyEncriptDataHive), // ); // Hive.registerAdapter(depositModelAdapter()); // Hive.registerAdapter(CategoriesModelAdapter()); // Hive.registerAdapter(pricesModelAdapter()); // Hive.registerAdapter(articleModelAdapter()); // Hive.registerAdapter(userModelAdapter()); // Hive.registerAdapter(EntrepriseModelAdapter()); // // print("path database==> ${appDocumentDirectory.path.toString()}"); // } catch (e) { // print("errorInitHiver====> ${e.toString()}"); // } // Hive.initFlutter(); // print(appDocumentDirectory.toString()); // var status = await await Permission.storage.status; // if (!status.isGranted) { // status = await Permission.storage.request(); // if (!status.isGranted) { // // L'utilisateur a refusé les autorisations // // Gérer la situation en conséquence // return; // } else if (status.isGranted && appDocumentDirectory.exists() == true) { // final testFile = File('${appDocumentDirectory.path}/test.txt'); // await testFile.writeAsString('test'); // await testFile.delete();
// } // } }, ); runApp(const MyApp()); }
class MyApp extends StatelessWidget { const MyApp({super.key});
@override Widget build(BuildContext context) { //SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle( // statusBarColor: isImportData == true // ? Colors.blue // : Colors.white, // Changer la couleur ici // )); return ChangeNotifierProvider( create: (context) => articleProvider(), child: MultiProvider( providers: [ ChangeNotifierProvider(create: () => NetwordProvider()), ChangeNotifierProvider(create: () => LoginProvider()), ChangeNotifierProvider(create: () => pricesProvider()), // ChangeNotifierProvider(create: () => articleProvider()), ChangeNotifierProvider(create: () => userProvider()), ChangeNotifierProvider(create: () => depositProvider()), ChangeNotifierProvider(create: (_) => DepositCategoriesProvider()), ], child: MaterialApp( debugShowCheckedModeBanner: false, title: 'CERO UZISHA', theme: ThemeData( visualDensity: VisualDensity.adaptivePlatformDensity, colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple), useMaterial3: true, ), navigatorKey: navigatorKey, home: SplashScreen(), ), ), ); } }
import 'package:ceroapp/Screens/Depositcategories/controlleur/CategoriesProvider.dart'; import 'package:ceroapp/Screens/Depositcategories/model/categorieModel.dart'; import 'package:ceroapp/Screens/articles/controlleur/article_provider.dart'; import 'package:ceroapp/Screens/articles/model/article_model.dart'; import 'package:ceroapp/Screens/deposit/Model/depositMode.dart'; import 'package:ceroapp/Screens/deposit/controlleur/depositProvider.dart'; import 'package:ceroapp/Screens/entreprises/model/entreprise_model.dart'; import 'package:ceroapp/Screens/login/controlleur/login.provider.dart'; import 'package:ceroapp/Screens/prices/controlleur/price_provider.dart'; import 'package:ceroapp/Screens/prices/model/prices_model.dart'; import 'package:ceroapp/Screens/splash/splah_loading.dart'; import 'package:ceroapp/Screens/users/controlleur/user_provider.dart'; import 'package:ceroapp/Screens/users/model/user_model.dart'; import 'package:ceroapp/ressources/publicControlleurs/Api_provider.dart'; import 'package:flutter/material.dart'; import 'package:hive_flutter/adapters.dart'; import 'package:provider/provider.dart'; import 'package:shared_preferences/shared_preferences.dart';
final keyEncriptDataHive = Hive.generateSecureKey(); BoxCollection? collection; SharedPreferences? prefs; GlobalKey navigatorKey = GlobalKey();
void main() async { WidgetsFlutterBinding.ensureInitialized(); prefs = await SharedPreferences.getInstance();
await Hive.initFlutter(); WidgetsBinding.instance.addPostFrameCallback( (timeStamp) async { try { Hive.registerAdapter(ArticleAdapter()); Hive.registerAdapter(depositAdapter()); Hive.registerAdapter(CategoriesModelAdapter()); Hive.registerAdapter(EntrpriseModeAdapter()); Hive.registerAdapter(pricesModelAdapter()); Hive.registerAdapter(userModelAdapter()); await Hive.openBox(
'services_controllers',
crashRecovery: true,
collection: "ceroDb",
// encryptionCipher: HiveAesCipher(keyEncriptDataHive),
);
await Hive.openBox(
'deposits_users',
crashRecovery: true,
collection: "ceroDb",
// encryptionCipher: HiveAesCipher(keyEncriptDataHive),
);
await Hive.openBox(
'deposits_categories',
crashRecovery: true,
collection: "ceroDb",
// encryptionCipher: HiveAesCipher(keyEncriptDataHive),
);
await Hive.openBox(
'enterprises',
crashRecovery: true,
collection: "ceroDb",
// encryptionCipher: HiveAesCipher(keyEncriptDataHive),
);
await Hive.openBox(
'prices_categories',
crashRecovery: true,
collection: "ceroDb",
// encryptionCipher: HiveAesCipher(keyEncriptDataHive),
);
await Hive.openBox(
'user',
crashRecovery: true,
collection: "ceroDb",
// encryptionCipher: HiveAesCipher(keyEncriptDataHive),
);
} catch (e) {
print("error while initializing hive ====> ${e.toString()}");
}
// final appDocumentDirectory = await getApplicationDocumentsDirectory();
// try {
// // Hive.initFlutter();
// Hive.initFlutter(appDocumentDirectory.path);
// collection = await BoxCollection.open(
// 'db_cero',
// {
// 'user',
// 'enterprises',
// 'accounts',
// 'affectation_users',
// 'attemptactivationaccounts',
// 'bonuses',
// 'categories_customer_controllers',
// 'categories_services_controllers',
// 'cautions',
// 'colors',
// 'comments',
// 'customer_controllers',
// 'debts',
// 'debt_payments',
// 'decision_chiefdepartments',
// 'decision_decisionteams',
// 'decision_teams',
// 'defects',
// 'departments',
// 'deposits_categories',
// 'deposits_users',
// 'deposit_controllers',
// 'deposit_services',
// 'details_invoices_statuses',
// 'details_requests',
// 'document_types',
// 'expenditures',
// 'expenditures_limits',
// 'failed_jobs',
// 'fences',
// 'fence_ticketings',
// 'funds',
// 'images',
// 'invoices',
// 'invoicesdetailscolors',
// 'invoicesdetailsdefects',
// 'invoicesdetailsmaterials',
// 'invoicesdetailsreasons',
// 'invoicesdetails_spots',
// 'invoicesdetails_styles',
// 'invoices_statuses',
// 'invoice_details',
// 'materials',
// 'moneys',
// 'money_conversions',
// 'nbrdecisionteam_validations',
// 'orders',
// 'other_entries',
// 'owners',
// 'password_resets',
// 'paymentmodes',
// 'personal_access_tokens',
// 'points',
// 'point_of_sales',
// 'posdeposits',
// 'pressing_stock_stories',
// 'prices_categories',
// 'provider_controllers',
// 'reasons',
// 'requestapprovments',
// 'requests',
// 'request_files',
// 'request_histories',
// 'request_references',
// 'request_serveds',
// 'roles',
// 'safeguards',
// 'self_references',
// 'servants',
// 'servicesadditionalfees',
// 'services_controllers',
// 'spots',
// 'statuses',
// 'stock_history_controllers',
// 'styles',
// 'systeminfos',
// 'testmodesls',
// 'ticket_offices',
// 'unit_of_measure_controllers',
// 'tables',
// 'usersenterprises',
// 'users_expenditures_limits',
// 'users_point_of_sales',
// 'users_ticket_offices',
// 'validatedbydecisionteams'
// },
// // path: await getApplicationDocumentsDirectory() ,
// path: appDocumentDirectory.path,
// key: HiveAesCipher(keyEncriptDataHive),
// );
// Hive.registerAdapter(depositModelAdapter());
// Hive.registerAdapter(CategoriesModelAdapter());
// Hive.registerAdapter(pricesModelAdapter());
// Hive.registerAdapter(articleModelAdapter());
// Hive.registerAdapter(userModelAdapter());
// Hive.registerAdapter(EntrepriseModelAdapter());
// // print("path database==> ${appDocumentDirectory.path.toString()}");
// } catch (e) {
// print("errorInitHiver====> ${e.toString()}");
// }
// Hive.initFlutter();
// print(appDocumentDirectory.toString());
// var status = await await Permission.storage.status;
// if (!status.isGranted) {
// status = await Permission.storage.request();
// if (!status.isGranted) {
// // L'utilisateur a refusé les autorisations
// // Gérer la situation en conséquence
// return;
// } else if (status.isGranted && appDocumentDirectory.exists() == true) {
// final testFile = File('${appDocumentDirectory.path}/test.txt');
// await testFile.writeAsString('test');
// await testFile.delete();
// } // } }, ); runApp(const MyApp()); }
class MyApp extends StatelessWidget { const MyApp({super.key});
@override Widget build(BuildContext context) { //SystemChrome.setSystemUIOverlayStyle(SystemUiOverlayStyle( // statusBarColor: isImportData == true // ? Colors.blue // : Colors.white, // Changer la couleur ici // )); return ChangeNotifierProvider(
create: (context) => articleProvider(),
child: MultiProvider(
providers: [
ChangeNotifierProvider(create: () => NetwordProvider()),
ChangeNotifierProvider(create: () => LoginProvider()),
ChangeNotifierProvider(create: () => pricesProvider()),
// ChangeNotifierProvider(create: () => articleProvider()),
ChangeNotifierProvider(create: () => userProvider()),
ChangeNotifierProvider(create: () => depositProvider()),
ChangeNotifierProvider(create: (_) => DepositCategoriesProvider()),
],
child: MaterialApp(
debugShowCheckedModeBanner: false,
title: 'CERO UZISHA',
theme: ThemeData(
visualDensity: VisualDensity.adaptivePlatformDensity,
colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
useMaterial3: true,
),
navigatorKey: navigatorKey,
home: SplashScreen(),
),
),
);
}
}