mirror of
https://github.com/lollipopkit/flutter_server_box.git
synced 2025-12-17 07:14:28 +01:00
#54 new: grouped snippet & tab snippet
This commit is contained in:
@@ -8,16 +8,20 @@ class Snippet {
|
||||
late String name;
|
||||
@HiveField(1)
|
||||
late String script;
|
||||
Snippet(this.name, this.script);
|
||||
@HiveField(2)
|
||||
List<String>? tags;
|
||||
Snippet(this.name, this.script, {this.tags});
|
||||
|
||||
Snippet.fromJson(Map<String, dynamic> json) {
|
||||
name = json['name'].toString();
|
||||
script = json['script'].toString();
|
||||
tags = json['tags'].cast<String>();
|
||||
}
|
||||
Map<String, dynamic> toJson() {
|
||||
final data = <String, dynamic>{};
|
||||
data['name'] = name;
|
||||
data['script'] = script;
|
||||
data['tags'] = tags;
|
||||
return data;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,17 +19,20 @@ class SnippetAdapter extends TypeAdapter<Snippet> {
|
||||
return Snippet(
|
||||
fields[0] as String,
|
||||
fields[1] as String,
|
||||
tags: (fields[2] as List?)?.cast<String>(),
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void write(BinaryWriter writer, Snippet obj) {
|
||||
writer
|
||||
..writeByte(2)
|
||||
..writeByte(3)
|
||||
..writeByte(0)
|
||||
..write(obj.name)
|
||||
..writeByte(1)
|
||||
..write(obj.script);
|
||||
..write(obj.script)
|
||||
..writeByte(2)
|
||||
..write(obj.tags);
|
||||
}
|
||||
|
||||
@override
|
||||
|
||||
Reference in New Issue
Block a user