From a7f4838ce910893c4724ee4ce60c1572bff7e17d Mon Sep 17 00:00:00 2001 From: andrei Date: Wed, 3 Nov 2021 18:45:37 -0400 Subject: [PATCH] refresh checklist page --- lib/check_list.dart | 64 +++++++++++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 29 deletions(-) diff --git a/lib/check_list.dart b/lib/check_list.dart index 6db6180..9f3bdc3 100644 --- a/lib/check_list.dart +++ b/lib/check_list.dart @@ -45,8 +45,8 @@ class _CheckList extends State { @override void initState() { - _loadList(); _loadListData(); + _loadList(); super.initState(); } @@ -70,35 +70,41 @@ class _CheckList extends State { ] : [], ), - body: ListView.builder( - itemCount: list.length, - itemBuilder: (context, index) { - return Card( - child: CheckboxListTile( - title: TextFormField( - enabled: - (listData != null && (!listData!.isTemplate! || _editable)), - decoration: InputDecoration(border: InputBorder.none), - initialValue: list[index].text, - onChanged: (value) { - list[index].text = value; - _updateItem(list[index]); - }, - ), - controlAffinity: ListTileControlAffinity.leading, - value: list[index].value, - onChanged: - (listData != null && (!listData!.isTemplate! || _editable)) - ? ((value) { - _updateItem(list[index]); - setState(() { - list[index].value = value!; - }); - }) - : null, - ), - ); + body: RefreshIndicator( + onRefresh: () async { + _loadListData(); + _loadList(); }, + child: ListView.builder( + itemCount: list.length, + itemBuilder: (context, index) { + return Card( + child: CheckboxListTile( + title: TextFormField( + enabled: (listData != null && + (!listData!.isTemplate! || _editable)), + decoration: InputDecoration(border: InputBorder.none), + initialValue: list[index].text, + onChanged: (value) { + list[index].text = value; + _updateItem(list[index]); + }, + ), + controlAffinity: ListTileControlAffinity.leading, + value: list[index].value, + onChanged: + (listData != null && (!listData!.isTemplate! || _editable)) + ? ((value) { + _updateItem(list[index]); + setState(() { + list[index].value = value!; + }); + }) + : null, + ), + ); + }, + ), ), floatingActionButton: FloatingActionButton( onPressed: () {