SmartSearchMultiController<T, K> constructor
SmartSearchMultiController<T, K> ({
- required SmartPaginationCubit<
T> cubit, - required PaginationRequest searchRequestBuilder(
- String query
- SmartSearchConfig config = const SmartSearchConfig(),
- ValueChanged<
List< ? onSelectionChanged,T> > - ValueChanged<
List< ? onKeysChanged,K> > - List<
T> ? initialSelectedValues, - List<
K> ? selectedKeys, - K keyExtractor(
- T item
- String selectedKeyLabelBuilder(
- K key
- int? maxSelections,
Implementation
SmartSearchMultiController({
required SmartPaginationCubit<T> cubit,
required PaginationRequest Function(String query) searchRequestBuilder,
SmartSearchConfig config = const SmartSearchConfig(),
ValueChanged<List<T>>? onSelectionChanged,
ValueChanged<List<K>>? onKeysChanged,
List<T>? initialSelectedValues,
List<K>? selectedKeys,
K Function(T item)? keyExtractor,
String Function(K key)? selectedKeyLabelBuilder,
int? maxSelections,
}) : _cubit = cubit,
_searchRequestBuilder = searchRequestBuilder,
_config = config,
_onSelectionChanged = onSelectionChanged,
_onKeysChanged = onKeysChanged,
_keyExtractor = keyExtractor,
_selectedKeyLabelBuilder = selectedKeyLabelBuilder,
_selectedItems = List<T>.from(initialSelectedValues ?? []),
_selectedKeys = _initializeSelectedKeys(
initialSelectedValues,
selectedKeys,
keyExtractor,
),
_pendingKeys = selectedKeys != null && initialSelectedValues == null
? Set<K>.from(selectedKeys)
: <K>{},
_maxSelections = maxSelections {
_textController = TextEditingController();
_focusNode = FocusNode();
_textController.addListener(_onTextChanged);
_focusNode.addListener(_onFocusChanged);
// Listen to cubit state changes to sync pending keys with loaded data
if (_pendingKeys.isNotEmpty) {
_cubitSubscription = _cubit.stream.listen(_onCubitStateChanged);
}
}