This is a collection of sample Flutter apps based on Riverpod. While developing various apps I have used a variety of state management architectures/techniques such as
- setState
- Flutter BLoC
- Provider
each with their own way of providing a solution, usually depending on how complex (or simple) the app being written is. My current goto is Provider as it 'provides' a good solution that allows me to create a simple structured and repeatable codebase for each app.
I have now started, for various reasons, looking at Riverpod as an alternative, and so am starting with some simple scenarios that I have used in the past with Provider to see what the difference is and to experiment with how to restructure the codebase of any potential projects.
Please Note - this is by no means a best practices set of exercises it is a way for me to get to understand the many ways that an app could be architected using Riverpod in a way that relates to similar structures I have used with Provider
This is a list of the test projects, and hopefully the list will expand as I try out different things.
A simple use of StateProvider to track the status of an app and show a different screen depending on that status.
This is a clone of app_navigator but as the state of the app changes the status is persisted using shared_preferences. This means that even if the app is shut down when it is restarted it will navigate to the screen it was last on, rather than restarting each time. State persistence is optional and defaults to true.
Really an example of initialising a StateNotifier state value with the result of an async call.
An experiment to view the electricity use for 24 hours and look at the costs as the day goes forward. This is based on a set of smart meter readings that are taken every 30 mins, the data is an actual grab for 24 hours of use.
The kw/h values grabbed are then multiplied by a cost per kilowatt (the tariff) with an initial cost(the standing charge) also factored in. The slider allows you to view then changing cost of the electricity as the day progresses, highlighting the current section in green.