state_saver_package library

Classes

StateSaver
StateSaver class is used to save and restore application state. This class converts objects to JSON format and saves them to SharedPreferences, and converts data retrieved from SharedPreferences back to objects.

Functions

clearAllStates() Future<bool>
Convenience function for clearing all
clearState(String key) Future<bool>
Convenience function for clearing
loadState<T>(String key, {T? defaultValue, T fromJson(Map<String, dynamic>)?}) Future<T?>
Convenience function for loading
saveOnStateAction(Future<void> saveFunction()) → void
Adds a save function that will run automatically when the application is closed
saveState(String key, Object object) Future<bool>
Convenience function for saving
stateSaverListener() → void
Starts listening for save functions that will run when the application is closed This function should be called in the main() method of the application or before creating MaterialApp.