I am trying to find the problem, I even did a hot restart but its not working I'm stuck on it, Someone please look at it
The following ProviderNotFoundException was thrown building MessageList(dirty, state: MessageListState#24cda): Error: Could not find the correct Provider above this MessageList Widget
This happens because you used a BuildContext that does not include the provider
Main.dart
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await Firebase.initializeApp();
runApp(const App());
}
class App extends StatelessWidget {
const App({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MultiProvider(
providers: [
ChangeNotifierProvider<UserDao>(
lazy: false,
create: (_) => UserDao(),
),
],
child: Builder(builder: (context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'RayChat',
theme: ThemeData(primaryColor: const Color(0xFF3D814A)),
home: Consumer<UserDao>(builder: (context, userDao, child) {
if (userDao.isLoggedIn()) {
return const MessageList();
} else {
return const Login();
}
}),
);
}),
);
}
}