From 679fbd2f975c81a3dab2423952a970b763a2632e Mon Sep 17 00:00:00 2001 From: Felix Date: Mon, 12 Aug 2019 10:15:36 +0100 Subject: [PATCH] async organisations dialog works now --- lib/common/widgets/organisations_dialog.dart | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/lib/common/widgets/organisations_dialog.dart b/lib/common/widgets/organisations_dialog.dart index 91ddd34..ab8f374 100644 --- a/lib/common/widgets/organisations_dialog.dart +++ b/lib/common/widgets/organisations_dialog.dart @@ -25,17 +25,18 @@ class FindOrganisations { var listTitle = "All Organisations"; var organisationsList = organisations.getTestData(); - void _submitSearch(String search) async { + Future _submitSearch(String search) async { _searchEnabled = false; listTitle = "Results for \'" + search + "\'"; - var futureOrgs = organisations.findOrganisations(search); - futureOrgs.then((value) { - debugPrint("There are " + value.length.toString() + + var futureOrgs = await organisations.findOrganisations(search); +// futureOrgs.then((value) { + debugPrint("There are " + futureOrgs.length.toString() + " payees matching the query \'" + search + "\'."); - organisationsList = value; + organisationsList = futureOrgs; _searchEnabled = true; - }); + return futureOrgs.length; +// }); } return showDialog( @@ -69,8 +70,10 @@ class FindOrganisations { }, onSubmitted: (value) { if (_searchEnabled) { - _submitSearch(searchBarText.text); - setState(() => {}); + var result = _submitSearch(searchBarText.text); + result.then((_) { + setState(() {}); + }); } }, ),