Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 14 additions & 2 deletions lib/multiselect.dart
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ class DropDownMultiSelect<T> extends StatefulWidget {
final Widget Function(T option)? menuItembuilder;

/// a function to validate
final String Function(T? selectedOptions)? validator;
final String? Function(T? selectedOptions)? validator;

/// defines whether the widget is read-only
final bool readOnly;
Expand Down Expand Up @@ -142,7 +142,19 @@ class _DropDownMultiSelectState<TState> extends State<DropDownMultiSelect<TState
hint: widget.hint,
style: widget.hintStyle,
icon: widget.icon,
validator: widget.validator != null ? widget.validator : null,
// validator: widget.validator != null ? widget.validator : null,
validator: widget.validator != null
? (TState? value) {
// Check if the value is null or empty
if (value == null || (value is Iterable && value.isEmpty)) {
return widget.validator!(null);
}

// Call the provided validator function
return widget.validator!(value);
}
: null,

decoration: widget.decoration != null
? widget.decoration
: InputDecoration(
Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ environment:
dependencies:
flutter:
sdk: flutter
states_rebuilder: ^6.2.0
states_rebuilder: ^6.4.0

dev_dependencies:
flutter_test:
Expand Down