Closed aacevedocofrai closed 7 months ago
Update this way works:
import 'dart:developer';
import 'package:flutter/material.dart';
import 'package:flutter_data/flutter_data.dart';
import 'package:hooks_riverpod/hooks_riverpod.dart';
import 'package:poc_flutter_data/main.data.dart';
import 'package:poc_flutter_data/src/user_feature/user_screen.dart';
class UsersApp extends HookConsumerWidget {
const UsersApp({super.key});
@override
Widget build(BuildContext context, WidgetRef ref) {
// https://github.com/rrousselGit/riverpod/issues/875
final initializerProvider = FutureProvider<void>((ref) {
// initialize FD
// await ref.container.refresh(repositoryInitializerProvider.future);
ref.container.refresh(repositoryInitializerProvider);
// retry offline events
final _sub = ref.listen(offlineRetryProvider, (_, __) {});
// close offline retry subscription
ref.onDispose(() {
_sub.close();
});
});
return MaterialApp(
home: Scaffold(
body: Center(
child: ref.watch(initializerProvider).when(
error: (error, _) => Text(error.toString()),
loading: () => const Text('Loading...'),
data: (_) {
log('DATA');
// enable verbose
return const UsersScreen();
},
),
),
),
debugShowCheckedModeBanner: false,
);
}
}
Thank you for sharing the working version
Hello i tried, 1.5 and 1.6 the offline code you shared in the doc:
FYI I'm testing on web
but my app stay in loading state forever, if y remove it, it works with no problem