replaceAsyncDropDownItems<T> method
Replaces all existing cached dropdown items with a new list of items.
This is useful when you want to completely refresh the dropdown options without refetching from the API.
fieldName: The name of the async dropdown field to update.items: The new list of dropdown items to set.
Implementation
void replaceAsyncDropDownItems<T>(
String fieldName,
List<DropDownItemState<T>> items,
) {
final field = state.asyncDropDownField<T>(fieldName);
state.fields[fieldName] = field.copyWith(
cachedItems: List<DropDownItemState<T>>.from(items),
items: Future.value(items),
);
state = state.copyWith(fields: Map.from(state.fields));
}