You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
`@riverpod
class TestSchoolNotifier extends _$TestSchoolNotifier {
late GetSchoolsUseCase _getSchoolsUseCase;
late SchoolsRequest _request;
List _cacheSchools = [];
int currentPage = 1;
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
`@riverpod
class TestSchoolNotifier extends _$TestSchoolNotifier {
late GetSchoolsUseCase _getSchoolsUseCase;
late SchoolsRequest _request;
List _cacheSchools = [];
int currentPage = 1;
@OverRide
PaginationState build() {
state = PaginationStateInitial();
init();
return state;
}
void init() async {
state = PaginationStateLoading();
_getSchoolsUseCase = ref.read(getSchoolsUseCaseProvider);
_request = SchoolsRequest(page: currentPage, pageSize: 20);
final getSchools = await _getSchoolsUseCase.execute(_request);
_cacheSchools = getSchools.fold(
(l) {
state = PaginationStateError(l, StackTrace.current);
return [];
},
(r) {
return r;
},
);
state = PaginationStateData(_cacheSchools);
}
}
`
what is the best practice for initialState notifier with async func ?
Beta Was this translation helpful? Give feedback.
All reactions