mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 15:24:35 +01:00
37 lines
784 B
Dart
37 lines
784 B
Dart
import 'package:fl_lib/fl_lib.dart';
|
|
|
|
import 'package:server_box/data/model/server/private_key_info.dart';
|
|
|
|
class PrivateKeyStore extends PersistentStore {
|
|
PrivateKeyStore._() : super('key');
|
|
|
|
static final instance = PrivateKeyStore._();
|
|
|
|
void put(PrivateKeyInfo info) {
|
|
box.put(info.id, info);
|
|
box.updateLastModified();
|
|
}
|
|
|
|
List<PrivateKeyInfo> fetch() {
|
|
final keys = box.keys;
|
|
final ps = <PrivateKeyInfo>[];
|
|
for (final key in keys) {
|
|
final s = box.get(key);
|
|
if (s != null && s is PrivateKeyInfo) {
|
|
ps.add(s);
|
|
}
|
|
}
|
|
return ps;
|
|
}
|
|
|
|
PrivateKeyInfo? get(String? id) {
|
|
if (id == null) return null;
|
|
return box.get(id);
|
|
}
|
|
|
|
void delete(PrivateKeyInfo s) {
|
|
box.delete(s.id);
|
|
box.updateLastModified();
|
|
}
|
|
}
|