SettingsYaml.fromString constructor
Loads settings from a string.
The content
must be formatted like a standard yaml file would be:
var settings = SettingsYaml(content: '''
password: xxxx
user: xxxx
''', filePath: 'mysettings.yaml');
The filePath is the path/file name that will be used when save is called.
Implementation
SettingsYaml.fromString({required String content, required this.filePath}) {
/// don't try to load an empty settings file. It will end in tears.
if (content.trim().isEmpty) {
return;
}
_document = loadYamlDocument(content);
if (_document!.contents is YamlMap) {
final topMap = _document!.contents as YamlMap;
for (final pair in topMap.value.entries) {
valueMap[pair.key as String] = pair.value;
}
}
/// else the settings file was empty.
}