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