build method
Return an independent copy so callers cannot mutate the builder.
Implementation
Map<String, dynamic> build() {
final outputs = _listSection('outbounds');
if (outputs.isEmpty) {
throw StateError('Xray configuration needs at least one outbound');
}
final seen = <String>{};
for (final item in outputs) {
if (item is! Map || item['tag'] is! String ||
(item['tag'] as String).trim().isEmpty) {
throw StateError('Every outbound needs a nonempty tag');
}
if (!seen.add(item['tag'] as String)) {
throw StateError('Duplicate outbound tag: ${item['tag']}');
}
}
return _cloneMap(_config);
}