Ad
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.
Ad
Answer
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
Ad
source: stackoverflow.com
Related Questions
- → How do you create a 12 or 24 mnemonics code for multiple cryptocurrencies (ETH, BTC and so on..)
- → Flutter: input text field don't work properly in a simple example..... where am I wrong?
- → Can I customize the code formatting of Dart code in Atom?
- → Is it possible to develop iOS apps with Flutter on a Linux virtual machine?
- → Display SnackBar in Flutter
- → JSON ObjectMapper in Flutter
- → Material flutter app source code
- → TabBarSelection No such method error
- → How do I set the animation color of a LinearProgressIndicator?
- → Add different routes/screens to Flutter app
- → Is there a way to get the size of an existing widget?
- → How to share a file using flutter
- → Is there an easy way to find particular text built from RichText in a Flutter test?
Ad