Files
flutter_server_box/lib/data/store/container.dart
2024-01-27 21:11:40 +08:00

33 lines
760 B
Dart

import 'package:toolbox/data/model/container/type.dart';
import '../../core/persistant_store.dart';
const _keyConfig = 'providerConfig';
class DockerStore extends PersistentStore {
DockerStore() : super('docker');
String? fetch(String? id) {
return box.get(id);
}
void put(String id, String host) {
box.put(id, host);
box.updateLastModified();
}
ContainerType getType([String? id]) {
final cfg = box.get(_keyConfig + (id ?? ''));
if (cfg == null) {
return ContainerType.docker;
} else {
return ContainerType.values.firstWhere((e) => e.toString() == cfg);
}
}
void setType(String? id, ContainerType type) {
box.put(_keyConfig + (id ?? ''), type.toString());
box.updateLastModified();
}
}