简体   繁体   中英

Flutter : Is provider an alternative to the BLoC pattern?

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.

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM