How to Reinitialize Flutter Data

By calling repositoryInitializerProvider again with Riverpod’s refresh we can reinitialize Flutter Data.

class TasksApp extends HookConsumerWidget {
  @override
  Widget build(BuildContext context, WidgetRef ref) {
    return MaterialApp(
      home: RefreshIndicator(
        onRefresh: () async => ref.container.refresh(repositoryInitializerProvider.future),
        child: Scaffold(
          body: Center(
            child: ref.watch(repositoryInitializerProvider).when(
                  error: (error, _) => Text(error.toString()),
                  loading: () => const CircularProgressIndicator(),
                  data: (_) => TasksScreen(),
                ),
          ),
        ),
      ),
    );
  }
}