|
|
@ -11,6 +11,13 @@ class NotesCategorySelect extends StatelessWidget { |
|
|
|
if (initialValue != null) { |
|
|
|
if (initialValue != null) { |
|
|
|
onChanged(initialValue!); |
|
|
|
onChanged(initialValue!); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
categories.sort(); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// After sorting the empty category '' should be at the first place |
|
|
|
|
|
|
|
if (!categories.first.isNotEmpty) { |
|
|
|
|
|
|
|
categories.insert(0, ''); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
final List<String> categories; |
|
|
|
final List<String> categories; |
|
|
@ -18,8 +25,6 @@ class NotesCategorySelect extends StatelessWidget { |
|
|
|
final Function(String category) onChanged; |
|
|
|
final Function(String category) onChanged; |
|
|
|
final Function() onSubmitted; |
|
|
|
final Function() onSubmitted; |
|
|
|
|
|
|
|
|
|
|
|
late final _categories = categories..sort((final a, final b) => a.compareTo(b)); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@override |
|
|
|
@override |
|
|
|
Widget build(final BuildContext context) => Autocomplete<String>( |
|
|
|
Widget build(final BuildContext context) => Autocomplete<String>( |
|
|
|
initialValue: initialValue != null |
|
|
|
initialValue: initialValue != null |
|
|
@ -28,13 +33,6 @@ class NotesCategorySelect extends StatelessWidget { |
|
|
|
) |
|
|
|
) |
|
|
|
: null, |
|
|
|
: null, |
|
|
|
optionsBuilder: (final value) { |
|
|
|
optionsBuilder: (final value) { |
|
|
|
final categories = [ |
|
|
|
|
|
|
|
if (!_categories.contains('')) ...{ |
|
|
|
|
|
|
|
'', |
|
|
|
|
|
|
|
}, |
|
|
|
|
|
|
|
..._categories, |
|
|
|
|
|
|
|
]; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (value.text.isEmpty) { |
|
|
|
if (value.text.isEmpty) { |
|
|
|
return categories; |
|
|
|
return categories; |
|
|
|
} |
|
|
|
} |
|
|
|