有这个代码(它发生的地方[]
):
Future<List<User>> getRequest() async {
String url = "https://site.ru/list";
final response = await http.get(Uri.parse(url));
var responseData = json.decode(response.body);
List<User> users = [];
for (var singleUser in responseData) {
User user = User(
username: singleUser["username"],
password: singleUser["password"]);
users.add(user);
}
return users;
}
Flutter 报错:nosuchmethoderror the method [] was called on null,如何解决这个问题?