Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/dizoftteam/diz-core-storage-reader
Simple storage reader with universal interface
https://github.com/dizoftteam/diz-core-storage-reader
Last synced: 3 days ago
JSON representation
Simple storage reader with universal interface
- Host: GitHub
- URL: https://github.com/dizoftteam/diz-core-storage-reader
- Owner: DizoftTeam
- License: mit
- Created: 2023-11-12T00:05:01.000Z (12 months ago)
- Default Branch: master
- Last Pushed: 2023-11-12T00:13:18.000Z (12 months ago)
- Last Synced: 2023-11-13T00:20:59.377Z (12 months ago)
- Language: Dart
- Size: 10.1 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# diz-core-storage-reader
Simple universal storage reader for debug
## Usage
```dart
import 'package:diz_core_storage_reader/diz_core_storage_reader.dart';
import 'package:flutter/material.dart';///
/// Пример реализации интерфейса [StorageReader]
///
final class CustomStorageReader implements StorageReader {
CustomStorageReader(this.storage);///
/// Для примера будем хранить данные просто в [Map]
///
final Map storage;@override
Future read({required String key}) async => storage[key];@override
Future> readAll() async => storage;
}///
/// Создаем глобальный экземпляр читателя (для примера)
///
final StorageReader mStorageReader = CustomStorageReader({
'first': 'first value',
'second': 'second value',
});void main() {
WidgetsFlutterBinding.ensureInitialized();runApp(MyApp());
}class MyApp extends StatelessWidget {
const MyApp({super.key});@override
Widget build(BuildContext context) {
return MaterialApp(
home: HomePage(),
);
}
}class HomePage extends StatelessWidget {
const HomePage({super.key});@override
Widget build(BuildContext context) {
return Scaffold(
body: Column(
children: [
StorageValueProvider(
reader: mStorageReader,
child: Column(
children: [
StorageValue(
skey: 'first',
builder: (BuildContext context, String? value) {
return StorageValueView(
title: 'First key',
value: value,
);
},
),
StorageValue(
skey: 'second',
builder: (BuildContext context, String? value) {
return StorageValueView(
title: 'Second token',
value: value,
);
},
),
],
),
),
],
),
);
}
}
```