Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Do I need to dispose cubit instances?

I am new to flutter and bloc. As a matter of fact, I have just recently started using cubit. For learning purposes, I have created a simple app in which I use cubit for bloc functionality. In all the examples I found online, they suggest disposing the bloc instance in the UI. However, I didn't find something similar when it comes to cubit. So, my question is: Do I need to dispose the cubit instances and how? It worths mentioning here that I am using MultiBlocProvider.

like image 935
johnweak Avatar asked Mar 02 '23 01:03

johnweak


1 Answers

Bloc extends Cubit and Cubit extends Stream. Like any Stream in Dart it needs to be disposed when it is not necessary, and it has close method to do so. This method will be executed automatically if you are using BlocProvider

like image 150
Pavel Shastov Avatar answered May 16 '23 09:05

Pavel Shastov