'Dart FileUpdater works only on one field
I have this piece of code that should update a .plist file
Future<String> getJsonAsString() async{
var config = File('my_file.json');
var stringContents = await config.readAsString();
return stringContents;
}
Future<void> updateFields() async {
var data = jsonDecode(await getJsonAsString());
FileUpdater.updateFile(
File('file.plist'),
Plist(
'field1',
data['field1'],
),
);
FileUpdater.updateFile(
File('file.plist'),
Plist(
'field2',
data['field2'],
),
);
}
my_file.json is a very simple json file with no nested data, like this:
{"field1": "value1", "field2": "value2"}
and file.plist is structured like this:
...
<key>field1</key>
<string>some_value1</string>
<key>field2</key>
<string>some_value2</string>
...
When I run my code, what I obtain is that only some_value2 is changed and becomes value2, while filed1 still have some_value1, like this:
...
<key>field1</key>
<string>some_value1</string>
<key>field2</key>
<string>value2</string>
...
If I delete the second FileUpdater, field1 is correctly updated. Is there something wrong in my code that I can't see?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
