dbhelper init and minsdkversion changed

This commit is contained in:
SomnusVeritas
2023-11-08 10:48:20 +01:00
parent c5f5a8654c
commit b7ab47c1ec
3 changed files with 8 additions and 1 deletions

View File

@@ -4,6 +4,7 @@ import 'pages/dashboard_page.dart';
import 'services/dbhelper.dart';
void main() async {
WidgetsFlutterBinding.ensureInitialized();
await DbHelper.init();
runApp(const MyApp());
}

View File

@@ -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));
}
}