From d5afe48e2238a08750e876370ce430319b6cacc0 Mon Sep 17 00:00:00 2001 From: jchrist Date: Fri, 13 Mar 2020 10:15:55 +0200 Subject: [PATCH] Fixes #24 When widget is created or updated, there should be a check whether `selectedItems` now points to an invalid item (e.g. removed) --- lib/searchable_dropdown.dart | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/searchable_dropdown.dart b/lib/searchable_dropdown.dart index 489b1d0..7965272 100644 --- a/lib/searchable_dropdown.dart +++ b/lib/searchable_dropdown.dart @@ -447,12 +447,14 @@ class _SearchableDropdownState extends State> { } } if (selectedItems == null) selectedItems = []; + selectedItems.removeWhere((item) => item >= widget.items.length); super.initState(); } @override void didUpdateWidget(SearchableDropdown oldWidget) { super.didUpdateWidget(oldWidget); + selectedItems?.removeWhere((item) => item >= widget.items.length); } Widget get menuWidget {