capture static method

Implementation

static Future<AppSessionSnapshot> capture() async {
  return await RunnerBenchmark.async('lifecycle', 'capture', () async {
    final storage = StorageManager();
    final publicStorage = <String, dynamic>{};
    final secureStorage = <String, dynamic>{};
    for (final key in storage.getKeys()) {
      if (key.startsWith('enc_')) {
        secureStorage[key] = _copy(storage.read(key));
      } else {
        publicStorage[key] = _copy(storage.read(key));
      }
    }
    final keychain = await storage.getAllFromKeychain();
    return AppSessionSnapshot(
      publicStorage: publicStorage,
      secureStorage: secureStorage,
      keychain: {
        for (final entry in keychain.entries) entry.key: _copy(entry.value),
      },
      locale: Ensemble().getLocale(),
    );
  });
}