9

I know that BLoC in flutter acts like the viewmodel layer in android's MVVM, so the data does not gets fetched again and again upon configuration changes (for ex: change in screen orientation).

I am confused if provider replaces the functionality of RxDart in BLoC pattern or it replaces the role BLoC pattern itself.

Also, if I don't use BLoC at all an only providers does the app survives configuration changes.

Please explain what are the limitations of provider over BLoC, RxDart combination with some use cases.

Suragch
  • 484,302
  • 314
  • 1,365
  • 1,393
curiousgeek
  • 903
  • 11
  • 18
  • "Provider is a dependency injection system built with widgets for widgets. provider is mostly syntax sugar for InheritedWidget, to make common use-cases straightforward." - BLoC is a pattern. They can be combined. – Rubens Melo Jun 11 '19 at 06:21

1 Answers1

11

Provider in itself doesn't replace the BLoC pattern. However, you can set up your architecture to use Provider in a way that could replace the BLoC pattern.

One way to do that would be to use the MVVM pattern, where you have a view model class that extends a ChangeNotifier. Then you can listen to that view model with a ChangeNotifierProvider so that the UI gets rebuilt any time the view model changes. FilledStacks does that well here.

See also

Personally I find it easier to use the builtin Flutter tools to manage state. I describe that more here:

Suragch
  • 484,302
  • 314
  • 1,365
  • 1,393