2022-10-29 18:06:20 +00:00
|
|
|
import 'package:flutter/foundation.dart';
|
2022-10-23 13:50:44 +00:00
|
|
|
import 'package:flutter/material.dart';
|
2022-10-31 18:29:58 +00:00
|
|
|
import 'package:permission_handler/permission_handler.dart';
|
2022-11-12 18:35:16 +00:00
|
|
|
import 'package:provider/provider.dart';
|
2022-10-29 19:39:08 +00:00
|
|
|
import 'package:sqflite/sqflite.dart';
|
2022-10-29 18:06:20 +00:00
|
|
|
import 'package:sqflite_common_ffi/sqflite_ffi.dart';
|
2022-10-23 13:50:44 +00:00
|
|
|
|
2022-10-29 20:55:38 +00:00
|
|
|
import 'app.dart';
|
2022-11-12 18:35:16 +00:00
|
|
|
import 'context/file_change_notifier.dart';
|
2022-10-29 20:55:38 +00:00
|
|
|
|
2022-10-31 18:29:58 +00:00
|
|
|
void main() async {
|
2022-10-29 18:06:20 +00:00
|
|
|
if (defaultTargetPlatform != TargetPlatform.android &&
|
|
|
|
defaultTargetPlatform != TargetPlatform.iOS) {
|
|
|
|
sqfliteFfiInit();
|
2022-10-29 19:39:08 +00:00
|
|
|
databaseFactory = databaseFactoryFfi;
|
2022-11-02 22:40:42 +00:00
|
|
|
} else {
|
|
|
|
WidgetsFlutterBinding.ensureInitialized();
|
2022-10-31 18:29:58 +00:00
|
|
|
|
2022-11-02 22:40:42 +00:00
|
|
|
Map<Permission, PermissionStatus> statuses =
|
|
|
|
await [Permission.manageExternalStorage, Permission.storage].request();
|
2022-10-31 18:29:58 +00:00
|
|
|
|
2022-11-02 22:40:42 +00:00
|
|
|
if (statuses.containsValue(PermissionStatus.denied)) {
|
|
|
|
// todo some error handling
|
|
|
|
}
|
2022-10-31 18:29:58 +00:00
|
|
|
}
|
|
|
|
|
2022-11-12 18:35:16 +00:00
|
|
|
runApp(ChangeNotifierProvider(
|
|
|
|
create: (ctx) {
|
|
|
|
return FileChangeNotifier()..loadAllNotes();
|
|
|
|
},
|
|
|
|
child: MaterialApp(
|
|
|
|
home: const App(),
|
|
|
|
theme:
|
|
|
|
ThemeData(appBarTheme: const AppBarTheme(color: Colors.blueGrey)),
|
|
|
|
)));
|
2022-10-23 13:50:44 +00:00
|
|
|
}
|