mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
46 lines
970 B
Dart
46 lines
970 B
Dart
import 'dart:convert';
|
|
|
|
import 'package:hive_flutter/hive_flutter.dart';
|
|
|
|
part 'private_key_info.g.dart';
|
|
|
|
@HiveType(typeId: 1)
|
|
class PrivateKeyInfo {
|
|
@HiveField(0)
|
|
late String id;
|
|
@HiveField(1)
|
|
late String privateKey;
|
|
@HiveField(2)
|
|
late String password;
|
|
|
|
PrivateKeyInfo(
|
|
this.id,
|
|
this.privateKey,
|
|
this.password,
|
|
);
|
|
PrivateKeyInfo.fromJson(Map<String, dynamic> json) {
|
|
id = json["id"].toString();
|
|
privateKey = json["private_key"].toString();
|
|
password = json["password"].toString();
|
|
}
|
|
Map<String, dynamic> toJson() {
|
|
final Map<String, dynamic> data = <String, dynamic>{};
|
|
data["id"] = id;
|
|
data["private_key"] = privateKey;
|
|
data["password"] = password;
|
|
return data;
|
|
}
|
|
}
|
|
|
|
List<PrivateKeyInfo> getPrivateKeyInfoList(dynamic data) {
|
|
List<PrivateKeyInfo> ss = [];
|
|
if (data is String) {
|
|
data = json.decode(data);
|
|
}
|
|
for (var t in data) {
|
|
ss.add(PrivateKeyInfo.fromJson(t));
|
|
}
|
|
|
|
return ss;
|
|
}
|