What is ScopedModel / BLoC Pattern?

Technology CommunityCategory: FlutterWhat is ScopedModel / BLoC Pattern?
VietMX Staff asked 3 years ago

ScopedModel and BLoC (Business Logic Components) are common Flutter app architecture patterns to help separate business logic from UI code and using fewer Stateful Widgets.

  • Scoped Model is a third-party package that is not included into Flutter framework. It’s a set of utilities that allow you to easily pass a data Model from a parent Widget down to its descendants. In addition, it also rebuilds all of the children that use the model when the model is updated. This library was originally extracted from the Fuchsia codebase.
  • BLoC stands for Business Logic Components. It helps in managing state and make access to data from a central place in your project. The gist of BLoC is that everything in the app should be represented as stream of events: widgets submit events; other widgets will respond. BLoC sits in the middle, managing the conversation.