diff --git a/dengue_app/lib/views/report_incident.dart b/dengue_app/lib/views/report_incident.dart index 34fb18e..83fbe0a 100644 --- a/dengue_app/lib/views/report_incident.dart +++ b/dengue_app/lib/views/report_incident.dart @@ -478,7 +478,22 @@ 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; + widget.setDistrictFunction(selectedDistrict); + }); + } + } + + @override Widget build(BuildContext context) { return DropdownButtonFormField(