From b8b91154573b62f99b3dff581d7828df7f4097ac Mon Sep 17 00:00:00 2001 From: anthonycicc Date: Sat, 19 May 2018 15:18:11 -0400 Subject: [PATCH] Added SnackBar on successful save --- lib/NoZeroDays.dart | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/lib/NoZeroDays.dart b/lib/NoZeroDays.dart index c0ec6f4..1a37b30 100644 --- a/lib/NoZeroDays.dart +++ b/lib/NoZeroDays.dart @@ -42,12 +42,12 @@ class _NoZeroDaysState extends State { setState( () => _zerodayslist.add(new Entry(highestID + 1, date, whatyoudid))); - _save(); + _save(context); } void _removeEntry(Entry entry) { _zerodayslist.removeWhere((testEntry) => testEntry.id == entry.id); - _save(); + _save(context); } void _editEntry(Entry entry) { @@ -141,8 +141,9 @@ class _NoZeroDaysState extends State { ); } - void _save() { + void _save(BuildContext context) { f.writeFile(json.encode(_zerodayslist)); + Scaffold.of(context).showSnackBar(new SnackBar(content: new Text("Saved"))); } void _load() { @@ -169,7 +170,11 @@ class _NoZeroDaysState extends State { // than having to individually change instances of widgets. return new Scaffold( appBar: new AppBar(title: new Text(widget.title), actions: [ - new IconButton(icon: new Icon(Icons.save), onPressed: _save), + new IconButton( + icon: new Icon(Icons.save), + onPressed: (() { + _save(context); + })), new IconButton(icon: new Icon(Icons.file_upload), onPressed: _load), ]), body: new Scaffold(body: new ListView.builder(