import 'dart:convert'; import 'dart:io'; import 'package:flutter/services.dart'; class Person { late String img; late String name; late bool senator; late String? description; Person({ required this.img, required this.name, required this.senator, this.description, }); Person.fromJson(Map json) { img = json['image']; name = json['name']; senator = json['senator'] == true.toString(); description = json['description']; } } Future> getPeopleList() async { String data = await rootBundle.loadString('assets/data.json'); List map = jsonDecode(data)["people"]; List people = []; for (int i = 0; i < map.length - 1; i++) { people.add(Person.fromJson(map[i])); } return people; }