Flutter local storage inspector
This library allows you to inspect your apps local storage at runtime. During development, use the "Local storage inspector" plugin in your IntelliJ based IDE to inspect and modify the local files, databases, models, ... of your app
Features
- Plugin for shared preferences
- Plugin for secure storage
- Plugin for local files (based on dart:io)
- Plugin for drift databases
Getting started
The local storage inspector can handle any number of server instances you pass to it. To start, create the storage inspector driver:
final driver = StorageServerDriver(
bundleId: 'com.example.test', //Used for identification
port: 0, //Default 0, use 0 to automatically use a free port
icon: '...' //Optional icon to visually identify the server. Base64 png or plain svg string
);
Adding servers
Once the driver is created, you can register the individual servers you wish to expose. These servers come as plugin packages to this package. Eg:
- files: file_local_storage_inspector
- preferences: preferences_local_storage_inspector
- secure storage: secure_storage_local_storage_inspector
final preferencesServer =
PreferencesKeyValueServer(preferences, 'Base Preferences');
final secureStorageServer =
SecureStorageKeyValueServer(secureStorage, 'Super secret storage');
final fileServer = DefaultFileServer('<cache dir path>', "Cache files");
driver.addKeyValueServer(preferencesServer);
driver.addKeyValueServer(secureStorageServer);
driver.addFileServer(fileServer);
Start inspector
Once all the servers have been configured, you can start the driver to start the inspector and announcement server for the plugin:
await driver.start();
Shutdown
If so required, you can shut down the server:
await driver.stop();
Advanced usage
Pausing
If you want to instrument some local storage before the application fully starts, you can start the driver with the paused: true
argument. This will ensure that
await driver.start(paused: true)
only returns when the inspector plugin/API sends the resume
signal. The server does handle requests before this signal, allowing you to change
initial values on the fly.
Writing custom integrations
To write your own integration into the system (eg: modify pure in-memory key value store, ...), simply implement the correct server interface that most closely matches your requirements.
abstract class KeyValueServer{} //Most generic key-value server. Supports arbitrary key and value types
abstract class SimpleKeyValueServer{} //Simpler variant of the key value server, supports only string keys and values
abstract class FileServer{} //Server that server hierarchical storage of binary data