This repository has been archived by the owner on Feb 9, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
State management: Migrate to bloc pattern/library (#10)
Migrate `ChangeNotifier` implementations to Cubits from the `flutter_bloc` library. Cubits were chosen over Blocs as the latter seems like it would just add the overhead of events (as compared to a direct function call) without added benefits that events might provide in other cases. Compared to the implementaion based on Provider, this version doesn't "crash" when resetting the valid T&C version. Instead, a listener (on `BlocConsumer`) detects that the T&C acceptance state has changed and triggers a refresh. Being straightforward with Bloc, Proivder doesn't solve problems like this. Unfortunately, we cannot get the listener to trigger on the initial value and therefore still need the component to be stateful (to use `initState`). The proper solution is probably to replace the initial loading of shared preferences with a more general initialization procedure which also fetches the valid T&C. Apart from this difference, the two implementations are clearly very similar. Still, I find that bloc does add some niceties like `onChange` and more structure like a repository abstraction. And it of course have many features that we haven't even touched here. In conclusion, Bloc seems to be strictly more powerful than Provider as the two solutions being very similar use basically the entire feature set of Provider but relatively little of that of Bloc.
- Loading branch information
Showing
7 changed files
with
96 additions
and
50 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters