hive implementation

save todo in hive
first release
This commit is contained in:
2023-09-29 11:22:28 +02:00
parent 37719bd696
commit 979fcfa2a1
8 changed files with 631 additions and 98 deletions

27
lib/data/database.dart Normal file
View File

@@ -0,0 +1,27 @@
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);
}
}