sharath
sharath

Reputation: 3626

Using BLoC in Flutter - Usage in Stateful widgets vs Stateless Widgets

While using BLoC in flutter, whats the difference between defining the BlocBuilder / BlocListener in A Stateful widgets vs a Stateless widget ?

Can't we always use Stateless widgets as bloc takes care of rebuilding the widget for us ? Are there any usecases where you might want to use a Stateful widget instead ?

PS : I am experimenting with the flutter_bloc 1.0.0 package for flutter (https://pub.dev/packages/flutter_bloc).

Upvotes: 3

Views: 2157

Answers (1)

Kris
Kris

Reputation: 3371

You can use stateless weights throughout the app as any rebuilding can be handled by the builder methods in StreamBuilder or BlocBuilder. There is no requirement to do so, though it is generally recommended, but it might make sense to make some small widget stateful if you want a click to toggle some information or display the button that interacts with the bloc.

Upvotes: 6

Related Questions