There are several steps involved in implementing a BLoC in your app: I'll highlight them here so that we have a map for the next few steps:
- Create a class that will serve as the BLoC.
- In the class, declare the data that needs to be updated in the app (in this case, the list of Todo objects).
- Set the StreamControllers.
- Create the getters for streams and sinks.
- Add the logic of the BLoC.
- Add a constructor in which you'll set data
- and listen to changes.
- Set the dispose() method.
- From the UI, create an instance of the BLoC.
- Use a StreamBuilder to build the widgets that will use the BLoC data.
- Add events to the sink for any changes to the data.
- Call the dispose() method.
I'll use this list as a map for the steps that we will perform in the remainder of this chapter.