storage_repository 0.0.2 copy "storage_repository: ^0.0.2" to clipboard
storage_repository: ^0.0.2 copied to clipboard

outdated

Abstraction for persisting and reading data to platform specific storage. Best used with dependency injection approach.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:storage_repository/storage_repository.dart';

Future main() async {
  final storageRepository = StorageRepository();
  //Or use like this to support dependency injection
  IStorageRepository concreteStorageRepository = StorageRepository();

  //Initialize like this(if you want to separate storage by some parameter)
  await storageRepository.init(prefix: 'current_user_id');

  storageRepository.set('key', 'dynamic value');
  concreteStorageRepository.set('key2', 1);

  final firstValue = storageRepository.get('key');
  final secondValue = concreteStorageRepository.get('key2');

  assert(firstValue == 'dynamic value');
  assert(secondValue == 1);

  assert(storageRepository.containsKey('key'));

  storageRepository.delete('key');

  assert(!storageRepository.containsKey('key'));

  storageRepository.log();

  storageRepository.clear();

  runApp(App());
}

class App extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Column(
          children: [
            Expanded(
              child: Text(''),
            ),
          ],
        ),
      ),
    );
  }
}
6
likes
0
pub points
64%
popularity

Publisher

unverified uploader

Abstraction for persisting and reading data to platform specific storage. Best used with dependency injection approach.

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

flutter, hive, hive_flutter

More

Packages that depend on storage_repository