GCWizard
GCWizard copied to clipboard
GCWDropDownButton: Automatically order items
Add an option to order the items.
E.g.: Numeral Words: Currently all items are unordered. So just add a
if (widget.ordered)
items.sort((a, b) => a.child.compareTo(b.child));
Interesting point is that there are items, which need to be ordered top nonetheless. For example the "All languages" entry at the numeral words text search. So this GCWDropDownItem must get a flag for orderedTop
. That make the order algorithm a bit more complicated. Like this:
if (widget.ordered)
items.sort((a,b) {
if (a.orderedTop) return -1;
if (b.orderedTop) return 1;
return a.child.compareTo(b.child);
})