fix init database
This commit is contained in:
@@ -11,7 +11,7 @@ class QuickReminder extends StatefulWidget {
|
|||||||
}
|
}
|
||||||
|
|
||||||
class _QuickReminderState extends State<QuickReminder> {
|
class _QuickReminderState extends State<QuickReminder> {
|
||||||
NoteDatabase db = NoteDatabase.instance;
|
NoteDatabase noteDatabase = NoteDatabase.instance;
|
||||||
|
|
||||||
@override
|
@override
|
||||||
Widget build(BuildContext context) {
|
Widget build(BuildContext context) {
|
||||||
@@ -24,8 +24,9 @@ class _QuickReminderState extends State<QuickReminder> {
|
|||||||
decoration: const InputDecoration(
|
decoration: const InputDecoration(
|
||||||
labelText: 'New Reminder',
|
labelText: 'New Reminder',
|
||||||
),
|
),
|
||||||
onSubmitted: (String value) {
|
onSubmitted: (String value) async{
|
||||||
db.addPromemoria(Promemoria.today(
|
final db = await noteDatabase.database;
|
||||||
|
noteDatabase.addPromemoria(Promemoria.today(
|
||||||
value,
|
value,
|
||||||
DateTime.now().toString(),
|
DateTime.now().toString(),
|
||||||
DateTime.now().toString(),
|
DateTime.now().toString(),
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ class _TodayViewState extends State<TodayView> {
|
|||||||
|
|
||||||
List<Promemoria> listaPromemoria = [];
|
List<Promemoria> listaPromemoria = [];
|
||||||
|
|
||||||
NoteDatabase db = NoteDatabase.instance;
|
NoteDatabase noteDatabase = NoteDatabase.instance;
|
||||||
|
|
||||||
/*[
|
/*[
|
||||||
Promemoria.today("Primo promemoria", DateTime.now().toString(), DateTime.now().toString(), DateTime.now().toString(), "Descrizione primo promemoria"),
|
Promemoria.today("Primo promemoria", DateTime.now().toString(), DateTime.now().toString(), DateTime.now().toString(), "Descrizione primo promemoria"),
|
||||||
@@ -27,7 +27,8 @@ class _TodayViewState extends State<TodayView> {
|
|||||||
];*/
|
];*/
|
||||||
|
|
||||||
getAllPromemoria() async {
|
getAllPromemoria() async {
|
||||||
List<Promemoria> temp = await db.getAllPromemoria() as List<Promemoria>;
|
final db = await noteDatabase.database;
|
||||||
|
List<Promemoria> temp = await noteDatabase.getAllPromemoria() as List<Promemoria>;
|
||||||
setState(() {
|
setState(() {
|
||||||
listaPromemoria = temp;
|
listaPromemoria = temp;
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user