FilledStacks / flutter-tutorials

The repo contains the source code for all the tutorials on the FilledStacks Youtube channel.
MIT License
4.75k stars 1.76k forks source link

010-provider-architecture Not load post #69

Closed sercheo87 closed 4 years ago

sercheo87 commented 4 years ago

Hi, I has a problem when run Final example not load post because is produced by Provider.of<User>(context).id in file home_view.dart has 0 on first run.

sercheo87 commented 4 years ago

I found difference when use provider: ^2.0.1 run without problems but use provider: ^4.0.4 is the problem the model not set value user id.

FilledStacks commented 4 years ago

Aaah, nice catch. You might have to handle your initial data different then. Check if there's updated docs and follow that from the provider readme

quajodk commented 4 years ago

I followed your tutorials to build an app same architecture as this the youtube tutorials. the issue I'm having is on app startup the provider.of<User>(context) is null. Though I'm managing that with a loader it throws the error on emulator.

quajodk commented 4 years ago

I found the issues it got to do with lazy loading of the create callback of provider in version 4, I just pass lazy: false to the provider.

heinzan commented 4 years ago

same too happen in me how solve that?My first time id is zero Please point me thanks.

quajodk commented 4 years ago

In the tutorial @FilledStacks used initial value in the user model which is passed to the provider in the first load. You don't necessarily need the initial values, so comment or take them out.

FilledStacks commented 4 years ago

@heinzan there's two solutions above your comment I hope you tried both. Update version to latest and set lazy to false.