Problem related to change notifier provider in flutter
533
Just add with ChangeNotifier
to MyUser
class.
class MyUser with ChangeNotifier {}
Author by
Mike Osborn
Updated on December 31, 2022Comments
-
Mike Osborn over 1 year
I am getting an error when using
changenotifierprovider
in my flutter project.Error:
'MyUser' doesn't conform to the bound 'ChangeNotifier?' of the type parameter 'T'. Try using a type that is or is a subclass of 'ChangeNotifier?'.
Class:
class SettingsForm extends StatefulWidget { static Widget getWidget() { return new Provider( create: (_) => MyUser(uid: ''), child: ChangeNotifierProvider( <-- here **ChangeNotifierProvider** create: (BuildContext context) => MyUser(uid: ''), builder: (_, _) => SettingsForm()), ) ); }