Error on line 60, column 2 of pubspec.yaml: Expected a key while parsing a block mapping. ╷ 60 │ assets: │ ^ ╵ Process finished with exit code 65
i need to show data from json file
Error on line 60, column 2 of pubspec.yaml: Expected a key while parsing a block mapping. ╷ 60 │ assets: │ ^ ╵ Process finished with exit code 65
i need to show data from json file
you can user dart:convert API. you can use JsonCodec class to parse data from json file.
here is an example .
{
"name": "John Doe",
"age": 30,
"email": "johndoe@example.com"
}
String jsonData = await rootBundle.loadString('assets/data.json');
dynamic data = json.decode(jsonData);
String name = data['name'];
int age = data['age'];
String email = data['email'];