-
Notifications
You must be signed in to change notification settings - Fork 23
Open
Description
I combined Riverpod to process the screen and data.
Currently, the package only supports Stream.
I cannot display the Loading state of the data on the screen.
Is it possible to support Future? Or is there a way to know the Data Loading state?
Note that I am not using 'StreamBuilder'.
Even after changing to 'StreamNotifier', the issue remains the same.
@riverpod
class ItemPagingAlgoliaController extends _$ItemPagingAlgoliaController {
late final HitsSearcher hitsSearcher;
@override
FutureOr<AlgoliaDataState<ItemData>?> build({bool published = true}) {
state = AsyncValue.data(AlgoliaDataState<ItemData>( hitsPerPage: 20));
hitsSearcher = HitsSearcher(
applicationID: Env.algoliaApplicationID,
apiKey: Env.algoliaSearchOnlyKey,
indexName: AlgoliaCredentials.itemIndex,
);
hitsSearcher.responses.listen(_fetchDataUpdate); // ** Stream listen
return state.value;
}
void _fetchDataUpdate(){
...
update((s)=> s.copyWidth(items: items));
}
}
UI:
class _DataListScreen extends ConsumerWidget {
const _DataListScreen({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
var sts = ref.watch(itemPagingAlgoliaControllerProvider(published: true));
return sts.when(
data: (dataState) {
return _DataTableScreen(items: dataState?.items ??[]);
},
error: (s, t) => Text('Error'),
loading: () => const LoadingData()); //*** Loading not working..
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels