From b4a7db3a560e73fcad33fc1c48493b5d0ff648ab Mon Sep 17 00:00:00 2001 From: Darkshredder Date: Tue, 1 Dec 2020 09:53:14 +0530 Subject: [PATCH 1/2] fixed:Flutter app report incident screen drop-down selection bug --- dengue_app/lib/views/report_incident.dart | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/dengue_app/lib/views/report_incident.dart b/dengue_app/lib/views/report_incident.dart index 34fb18e..7576bf0 100644 --- a/dengue_app/lib/views/report_incident.dart +++ b/dengue_app/lib/views/report_incident.dart @@ -478,7 +478,21 @@ class _DistrictDropdownState extends State { return null; } - // todo fix bug on changing already selected dropdowns + + @override + void didUpdateWidget(DistrictDropdown oldWidget) { + super.didUpdateWidget(oldWidget); + if (widget.selectedProvince != oldWidget.selectedProvince) { + setState(() { + selectedDistrict = widget.districtList + .where((element) => element.provinceId == widget.selectedProvince.id) + .toList() + .first; + }); + } + } + + @override Widget build(BuildContext context) { return DropdownButtonFormField( From af2bc4b0e056f6cf4d553640b727baf65e7c12ca Mon Sep 17 00:00:00 2001 From: Darkshredder Date: Tue, 1 Dec 2020 10:45:10 +0530 Subject: [PATCH 2/2] fixes --- dengue_app/lib/views/report_incident.dart | 1 + 1 file changed, 1 insertion(+) diff --git a/dengue_app/lib/views/report_incident.dart b/dengue_app/lib/views/report_incident.dart index 7576bf0..83fbe0a 100644 --- a/dengue_app/lib/views/report_incident.dart +++ b/dengue_app/lib/views/report_incident.dart @@ -488,6 +488,7 @@ class _DistrictDropdownState extends State { .where((element) => element.provinceId == widget.selectedProvince.id) .toList() .first; + widget.setDistrictFunction(selectedDistrict); }); } }