Using SharedPreferences in tests
SharedPreferences actually provides an in-memory implementation, but it is not documented in the README. If you don't set it up, SharedPreferences throws a warning when it's used in tests:
MissingPluginException(No implementation found for method getAll on channel plugins.flutter.io/shared_preferences)
The solution is to run SharedPreferences.setMockInitialValues({ values }).
setMockInitialValues method - SharedPreferences class - shared_preferences library - Dart API
API docs for the setMockInitialValues method from the SharedPreferences class, for the Dart programming language.
I wish it was prominently shown in the package docs.
I did find a mention of it here: https://docs.flutter.dev/cookbook/persistence/key-value#testing-support
This ticket seems to say the method is deprecated, but as of today, it runs fine.