Flutter apps rarely start with complicated state.
At first, a Bloc or Cubit state often looks harmless:
class KidState { final Kid ? kid ; final bool isLoading ; final StateError ? error ;
const KidState ({ required this . kid , required this . isLoading , required this . error , }); }
Enter fullscreen mode
Exit fullscreen mode
This works until the screen becomes real.
You add initial loading. Then pull-to-refresh. Then a cached value. Then an empty state. Then an error that should not erase the old content. Then a retry. Then one more field with the same lifecycle.
Now the state is not simple anymore. It is implicit.
// What does this mean? kid != null && isLoading && error != null
Enter fullscreen mode
Exit fullscreen mode
Is the kid loaded? Is the screen refreshing? Did the refresh fail? Should the UI show the old kid, the error, or a full-screen loader?
The problem is not Bloc.…