easytodo/lib/data/database.dart

28 lines
644 B
Dart
Raw Normal View History

2024-03-27 06:55:26 +00:00
import 'package:hive_flutter/hive_flutter.dart';
class ToDoDataBase {
List toDoList = [];
// reference our box
final _myBox = Hive.box('mybox');
// run this method if this is the 1st time ever opening this app
void createInitialData() {
toDoList = [
["Use the + button at the bottom to add a new item.", false],
["Use the checkbox to mark as done.", true],
["Swipe right-to-left to delete item.", false],
];
}
// load the data from database
void loadData() {
toDoList = _myBox.get("TODOLIST");
}
// update the database
void updateDataBase() {
_myBox.put("TODOLIST", toDoList);
}
}