HubConfig.fromMap constructor
Builds the config from an already-parsed hub: section map (as
PluginContext.config['hub'] provides upstream).
Implementation
factory HubConfig.fromMap(
Map<String, dynamic> section, [
Map<String, String> environment = const {},
]) {
String? scalar(String key) => switch (section[key]) {
String s => s,
_ => null,
};
Map<String, String> stringMap(String key) =>
(section[key] as Map<String, dynamic>? ?? {})
.map((k, v) => MapEntry(k, v is String ? v : v.toString()));
return HubConfig(
url: environment[envUrl] ?? scalar('url'),
keyPath: environment[envKeyPath] ?? scalar('keyPath'),
name: environment[envName] ?? scalar('name'),
channels: stringMap('channels'),
channelSecrets: stringMap('channelSecrets'),
);
}