Could Not Find The Correct Provider - Flutter


Answer :

You need a builder bridge between ChangeNotifierProvider and Scaffold.



Provider package already has it's own builder called Consumer, you can use it like:



ChangeNotifierProvider<MySchedule>(
create: (context) => MySchedule(),
child: Consumer<MySchedule>(
builder: (context, provider, child) => Scaffold(....,


Check this link: https://pub.dev/packages/provider#reading-a-value



edit: builder is now create.



According to the latest version of the Provider package, the builder() method of ChangeNotifierProvider was changed to create().
So editing Esen Mehmet's version, this will work instead:



ChangeNotifierProvider(
create: (context) => MySchedule(), //change builder to create
child: Consumer<MySchedule>(
builder: (context, provider, child) => Scaffold(....,


Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android How Can I Convert A String To A Editable