I am developing mobile application with flutter using flutter hooks. I want to refresh Riverpod FuttureProvider using useEffect, but it doesn't work nicely...
My code is
@hwidget
Widget someWidget(BuildContext context) {
final futureProvider = useProvider(myFutureProvider);
useEffect(() {
context.refresh(futureProvider);
}, [someKeys]);
return searchFetch.when(
data: (data) => TextButton(
onPressed: () {
context.refresh(futureProvider);
},
child: Text('refresh')
),
loading: () => Text('Loading...'),
error: (error, stack) => Text('Error.'));
}
When tap TextButton, refresh works fine.(I can see 'Loading...' text.) However, refresh written by useEffect only updates the data and 'Loading...' text cannot be seen.
How should I rewrite it.