onLoad method
FutureOr<void>
onLoad(
- LoadEvent event,
- dynamic emit
)
Implementation
@override
FutureOr<void> onLoad(LoadEvent event, emit) async {
if (event.isRefresh) emit(LoadingState());
final errorOrOptions = await _getDictionaryUseCase(
GetDictionarParams(
dictionaryName: dictionaryName,
),
);
errorOrOptions.fold(
(error) => emit(
ErrorState(
title: error.title,
subtitle: error.detail,
onRepeat: () => add(
LoadEvent(
isRefresh: true,
),
),
),
),
(options) {
data = options;
data.mergeBy(
incoming: value,
keySelector: (item) => item.getId,
mergeStrategy: (oldItem, newItem) => newItem,
);
add(UpdateEvent());
},
);
}