28 lines
644 B
Dart
28 lines
644 B
Dart
|
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);
|
||
|
}
|
||
|
}
|