'Undefined class 'CurrentUser'

CurrentUser is undefine I am trying to figure out what has it changed to.If you know plz help

It's says Could not find the correct Provider above this Screen Widget

CurrentUser _currentUser = Provider.of<CurrentUser>(context, listen: false);


Solution 1:[1]

Initialize all your providers before materialApp, so you can access them

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  @override
  Widget build(BuildContext context) {
    return MultiProvider(
        providers: [
          ChangeNotifierProvider.value(
            value: Auth(),
          ),
          ChangeNotifierProvider.value(
            value: CurrentUser(),
          ),
        ],
        child: MaterialApp(
          home: HomePage(),
     ),);
  }
}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Behzod Faiziev