From b7ab47c1ec378efca491abea6f3d95d24f673f07 Mon Sep 17 00:00:00 2001 From: SomnusVeritas Date: Wed, 8 Nov 2023 10:48:20 +0100 Subject: [PATCH] dbhelper init and minsdkversion changed --- android/app/build.gradle | 2 +- lib/main.dart | 1 + lib/services/dbhelper.dart | 6 ++++++ 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/android/app/build.gradle b/android/app/build.gradle index 8fda82d..b2e4910 100644 --- a/android/app/build.gradle +++ b/android/app/build.gradle @@ -45,7 +45,7 @@ android { applicationId "com.example.get_stuff_done" // You can update the following values to match your application needs. // For more information, see: https://docs.flutter.dev/deployment/android#reviewing-the-gradle-build-configuration. - minSdkVersion flutter.minSdkVersion + minSdkVersion 23 targetSdkVersion flutter.targetSdkVersion versionCode flutterVersionCode.toInteger() versionName flutterVersionName diff --git a/lib/main.dart b/lib/main.dart index b52148f..4fbe0e1 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -4,6 +4,7 @@ import 'pages/dashboard_page.dart'; import 'services/dbhelper.dart'; void main() async { + WidgetsFlutterBinding.ensureInitialized(); await DbHelper.init(); runApp(const MyApp()); } diff --git a/lib/services/dbhelper.dart b/lib/services/dbhelper.dart index 5ee9cf5..77301ee 100644 --- a/lib/services/dbhelper.dart +++ b/lib/services/dbhelper.dart @@ -5,6 +5,7 @@ import '../models/todo.dart'; class DbHelper { static late Isar _isar; + static int get nextTodoId => _isar.todos.autoIncrement(); static init() async { final dir = await getApplicationDocumentsDirectory(); @@ -12,5 +13,10 @@ class DbHelper { schemas: [TodoSchema], directory: dir.path, ); + var todos = [ + Todo(id: nextTodoId, title: 'Get Stuff Done'), + Todo(id: nextTodoId, title: 'Some shit'), + ]; + _isar.write((isar) => isar.todos.putAll(todos)); } }