1

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

1 Answers1

0

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'];
Engr.Aftab Ufaq
  • 3,356
  • 3
  • 21
  • 47