Matthias Nott
2026-03-24 96c8bb5db1a2e0ced999a366e3cf28f9895ec39f
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
class ServerConfig {
  final String host;
  final int port;
  final String? localHost;
  final String? vpnHost;
  final String? macAddress;
  final String? mqttToken;
  const ServerConfig({
    required this.host,
    this.port = 8765,
    this.localHost,
    this.vpnHost,
    this.macAddress,
    this.mqttToken,
  });
  Map<String, dynamic> toJson() {
    return {
      'host': host,
      'port': port,
      if (localHost != null) 'localHost': localHost,
      if (vpnHost != null) 'vpnHost': vpnHost,
      if (macAddress != null) 'macAddress': macAddress,
      if (mqttToken != null) 'mqttToken': mqttToken,
    };
  }
  factory ServerConfig.fromJson(Map<String, dynamic> json) {
    return ServerConfig(
      host: json['host'] as String? ?? '',
      port: json['port'] as int? ?? 8765,
      localHost: json['localHost'] as String?,
      vpnHost: json['vpnHost'] as String?,
      macAddress: json['macAddress'] as String?,
      mqttToken: json['mqttToken'] as String?,
    );
  }
  ServerConfig copyWith({
    String? host,
    int? port,
    String? localHost,
    String? vpnHost,
    String? macAddress,
    String? mqttToken,
  }) {
    return ServerConfig(
      host: host ?? this.host,
      port: port ?? this.port,
      localHost: localHost ?? this.localHost,
      vpnHost: vpnHost ?? this.vpnHost,
      macAddress: macAddress ?? this.macAddress,
      mqttToken: mqttToken ?? this.mqttToken,
    );
  }
}