Files
todo/lib/data/database.dart
streaper2 979fcfa2a1 hive implementation
save todo in hive
first release
2023-09-29 11:22:28 +02:00

28 lines
483 B
Dart

import 'package:hive_flutter/hive_flutter.dart';
class ToDoDataBase {
List todoList = [];
//reference hive todo box
final _myBox = Hive.box('todoBox');
//init db
void createInitialData() {
todoList = [
["Make Tutorial", true],
["Buy car", false],
["Buy new wife", true],
["buy card", false],
];
}
//load data
void loadData() {
todoList = _myBox.get('todos');
}
void updateData() {
_myBox.put('todos', todoList);
}
}