Loading topic
setState handles the first kind well and handles the second kind poorly.6 min readconst constructors, null safety, and the difference between == and identical. You don't need any Bloc code yet. Everything here is plain Dart plus the equatable package, and the next chapters build Cubits on top of it.5 min readStreams. The code here is plain Dart, so you can run it without a widg5 min readCubit<int> with emit), you know how BuildContext relates to the widget tree, and you know that InheritedWidget lets descendants look up data from an ancestor. By the end you will know how BlocProvider creates and disposes a Cubit, how desce5 min readStatelessWidget and BuildContext, and have a Cubit with an Equatable state. It also assumes you have used BlocProvider to make4 min readBlocProvider and BlocBuilder, and that you can write a Cubit with an immutable Equatable state. It uses the TodosCubit and TodosState from the earlier chapters on async state.5 min reademit, model state with Equatable and copyWith, and use BlocProvider and BlocBuilder. It also assumes Dart 3 sealed classes and basic async/await. The state and repository types (TodosState, TodosStatus, TodosRepository) come from earl4 min reademit, provide it with BlocProvider, and have seen the on<Event> handler syntax. It also assumes you know Dart 3 sealed classes and basic Streams. The goal is a decision you can defend in a code review, not a rule like "always use Bloc".5 min readTodosState model and TodosRepository from earlier chapters, and you have written a basic flutter_test test. You will learn to assert the exact sequence of states a Cubit or Bloc emits, to stub a repository with mocktail, and4 min reademit. It assumes you can write a Cubit, wire it up with BlocProvider, and read basic Dart Stream code. Knowing the stream behavior explains several surprises: why a state sometimes doesn't rebuild the UI, why a late listener misses val4 min reademit does, and you are comfortable with Dart classes and @override. Earlier chapters covered all of that.5 min readhydrated_bloc is a package that saves state to local storage on every change and restores it the next time the Cubit is created. This chapter covers setup, ser4 min read