brianegan / flutter_architecture_samples

TodoMVC for Flutter
http://fluttersamples.com/
BSD 3-Clause "New" or "Revised" License
8.74k stars 1.71k forks source link

Provider example #134

Closed DFreds closed 4 years ago

DFreds commented 5 years ago

With the support of the new Provider library (as shown here), I think a new example would be worthwhile. It might help others weigh the pros and cons of it versus BLoC or Scoped Model.

Relevant docs: https://pub.dev/packages/provider

brianegan commented 5 years ago

Yep, makes sense! Overall, the example will be almost Identical to the scoped_model example.

Instead of extending the Model class, you'll either mixin or extend the ChangeNotifier class.

Instead of ScopedModel / ScopedModelDescendant, you'd use ChangeNotifierProvider & Consumer.

shakib609 commented 5 years ago

I already created a similar app with provider here. I would like to contribute to this. I can submit a PR after making necessary changes.

tuanbs commented 4 years ago

@shakib609 Thanks for the example using Provider, but after running the app, I see your app doesn't follow the app specification. It's better if you make it consistent with the spec.

shakib609 commented 4 years ago

@tuanbs I modified the ScopedModel example app to use Provider as @brianegan suggested. Did you by any chance check this app and not the PR #143?

tuanbs commented 4 years ago

@shakib609 Yes I checked and run that app but the UI is different from the app spec. I also checked the scoped_model example but I see it doesn't use provider in pubspec.yaml. Also, I'm able to run the scoped_model example on Android, but it doesn't work on iOS.

shakib609 commented 4 years ago

@tuanbs The app in my profile was not intended for this issue. Please check this one.

tuanbs commented 4 years ago

Hi @shakib609, thanks for this, it works now. I have to download the zip file (NOT the git clone ... cli) from here to get the provider example.

Also, I found you have the tutorial for this provider-example, but it's about your old app. So I think you should update this tutorial with the new one. @brianegan It's better if you could include the tutorial for each example in the README file. For example, I found the flutter_bloc example has this tutorial as well. Anyway, thank you very much for your great jobs guys. I learned a lot from it. Cheers.