finished implementation
This commit is contained in:
@@ -83,13 +83,19 @@ class Setting {
|
||||
|
||||
@JsonSerializable()
|
||||
class Bridge {
|
||||
final String type;
|
||||
@JsonKey(toJson: _transportToJson, fromJson: _transportFromJson)
|
||||
final TransportType type;
|
||||
final String source;
|
||||
@JsonKey(name: 'bridge_strings')
|
||||
final List<String>? bridges;
|
||||
|
||||
const Bridge({required this.type, required this.source, this.bridges});
|
||||
|
||||
static String _transportToJson(TransportType transport) => transport.value;
|
||||
|
||||
static TransportType _transportFromJson(dynamic json) =>
|
||||
TransportType.fromString(json as String)!;
|
||||
|
||||
factory Bridge.fromJson(Map<String, dynamic> json) => _$BridgeFromJson(json);
|
||||
|
||||
Map<String, dynamic> toJson() => _$BridgeToJson(this);
|
||||
|
||||
@@ -50,7 +50,7 @@ Map<String, dynamic> _$SettingToJson(Setting instance) => <String, dynamic>{
|
||||
};
|
||||
|
||||
Bridge _$BridgeFromJson(Map<String, dynamic> json) => Bridge(
|
||||
type: json['type'] as String,
|
||||
type: Bridge._transportFromJson(json['type']),
|
||||
source: json['source'] as String,
|
||||
bridges: (json['bridge_strings'] as List<dynamic>?)
|
||||
?.map((e) => e as String)
|
||||
@@ -58,7 +58,7 @@ Bridge _$BridgeFromJson(Map<String, dynamic> json) => Bridge(
|
||||
);
|
||||
|
||||
Map<String, dynamic> _$BridgeToJson(Bridge instance) => <String, dynamic>{
|
||||
'type': instance.type,
|
||||
'type': Bridge._transportToJson(instance.type),
|
||||
'source': instance.source,
|
||||
'bridge_strings': instance.bridges,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user