Flutter NoSuchMethodError:方法';[]和#x27;调用了null,但未收到值

Flutter NoSuchMethodError:方法';[]和#x27;调用了null,但未收到值,flutter,Flutter,我想更新此页面中的数据(电子邮件和身份证是传感器) 但我在更新个人资料页面时遇到了这个错误 E/flutter (15726): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: NoSuchMethodError: The method '[]' was called on null. E/flutter (15726): Receiver: null E/flutter (15726): Tried call

我想更新此页面中的数据(电子邮件和身份证是传感器)

但我在更新个人资料页面时遇到了这个错误

E/flutter (15726): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: NoSuchMethodError: The method '[]' was called on null.
E/flutter (15726): Receiver: null
E/flutter (15726): Tried calling: []("idcardnumber")
E/flutter (15726): #0      Object.noSuchMethod (dart:core-patch/object_patch.dart:54:5)
然后,当我单击按钮更新配置文件时,它返回null,但在控制台日志中显示该值

这是我的取回数据

Future<List<ProfileModel>> fetchdata() async {
    setState(() {
      loading = true;
    });
    var uri = Uri(
      scheme: 'http',
      host: '192.168.0.16',
      path: 'edufund-api/Api/getprofileaccountbyemail.php',
      queryParameters: {
        'email': [widget.email],
      },
    );
    final response = await http.get(uri,headers:{"Content-Type":
    "application/json"});
    if (response.statusCode == 200) {
      final data = jsonDecode(response.body);
      setState(() {
        _profilemodel.add(ProfileModel.fromJson(data));
        print(data);
        loading = false;
      });
    }
  }
我还是不明白,为什么它返回空值?因为这个值来自getprofile函数,它的返回方式如下

{"status":true,"message":"Successfully Get Profile Account Data!","acc_id":"1","idcardnumber":"3173044410970003","placeofbirth":"Jakarta","dateofbirth":"1997-11-04","Gender":"P","Religion":"Kristen","ImageKTP":"file:\/data\/user\/0\/host.exp.exponent\/cache\/ExperienceData\/%2540anonymous%252FEdufundMobileNew-2ab8f886-79ea-49e4-adb1-d20e477003bb\/ImagePicker\/c3a4f457-624e-47d0-9564-d8f0a509c089.jpg","ImageSelfie":"file:\/data\/user\/0\/host.exp.exponent\/cache\/ExperienceData\/%2540anonymous%252FEdufundMobileNew-2ab8f886-79ea-49e4-adb1-d20e477003bb\/ImagePicker\/66bd90ef-0d72-465c-9534-d41563f914e2.jpg","StatusMarriage":"Not Married","Education":"S1","TaxID":"1","ImageFamilyMemberCard":"file:\/data\/user\/0\/host.exp.exponent\/cache\/ExperienceData\/%2540anonymous%252FEdufundMobileNew-2ab8f886-79ea-49e4-adb1-d20e477003bb\/ImagePicker\/e8bb08b3-6b49-4652-9e3a-a7688cc05f5d.jpg","Occupation":"Indonesia","Fields":"Technology","Position":"Staff","StatusOfEmployment":"Intern","ProofOfEmployment":"Internship","ProofOfIncome":"1000000","ProofOfBusiness":"Store","ProofOfBusinessIncome":"1500000","Type":"Data","Status":"Active","Village_ID":"3","Province_ID":"1","Street":"Jalan dharma griya v","Number":"79","RT":"7","RW":"12","City":"Jakarta Barat","SubDistrict":"Semanan","PostalCode":"11850","ResidentialStatus":"Active","Duration":"20","ProofOfResidence":"House","Name":"Jess","Phone":"081915543390","Relationship":"Cousin"}
这是获取配置文件函数

 static Future<ProfileModel> getprofile({String email, String idUser, String url}) async  {
    var uri = Uri(
      scheme: 'http',
      host: '192.168.0.16',
      path: 'edufund-api/Api/getprofileaccountbyemail.php',
      queryParameters: {
        'email': [email],
      },
    );
    print(uri);
    final response = await http.get(uri,headers:{"Content-Type":
    "application/json"},
    );
    var res = ProfileModel.fromJson(jsonDecode(response.body)[0]);
    print(response.body);
    return res;
  }
static Future getprofile({String email,String idUser,String url})异步{
var uri=uri(
方案:“http”,
主机:“192.168.0.16”,
路径:“edufund api/api/getprofileaccountbyemail.php”,
查询参数:{
“电子邮件”:[电子邮件],
},
);
打印(uri);
最终响应=等待http.get(uri,头:{“内容类型”:
“application/json”},
);
var res=ProfileModel.fromJson(jsonDecode(response.body)[0]);
打印(响应.正文);
返回res;
}
{"status":true,"message":"Successfully Get Profile Account Data!","acc_id":"1","idcardnumber":"3173044410970003","placeofbirth":"Jakarta","dateofbirth":"1997-11-04","Gender":"P","Religion":"Kristen","ImageKTP":"file:\/data\/user\/0\/host.exp.exponent\/cache\/ExperienceData\/%2540anonymous%252FEdufundMobileNew-2ab8f886-79ea-49e4-adb1-d20e477003bb\/ImagePicker\/c3a4f457-624e-47d0-9564-d8f0a509c089.jpg","ImageSelfie":"file:\/data\/user\/0\/host.exp.exponent\/cache\/ExperienceData\/%2540anonymous%252FEdufundMobileNew-2ab8f886-79ea-49e4-adb1-d20e477003bb\/ImagePicker\/66bd90ef-0d72-465c-9534-d41563f914e2.jpg","StatusMarriage":"Not Married","Education":"S1","TaxID":"1","ImageFamilyMemberCard":"file:\/data\/user\/0\/host.exp.exponent\/cache\/ExperienceData\/%2540anonymous%252FEdufundMobileNew-2ab8f886-79ea-49e4-adb1-d20e477003bb\/ImagePicker\/e8bb08b3-6b49-4652-9e3a-a7688cc05f5d.jpg","Occupation":"Indonesia","Fields":"Technology","Position":"Staff","StatusOfEmployment":"Intern","ProofOfEmployment":"Internship","ProofOfIncome":"1000000","ProofOfBusiness":"Store","ProofOfBusinessIncome":"1500000","Type":"Data","Status":"Active","Village_ID":"3","Province_ID":"1","Street":"Jalan dharma griya v","Number":"79","RT":"7","RW":"12","City":"Jakarta Barat","SubDistrict":"Semanan","PostalCode":"11850","ResidentialStatus":"Active","Duration":"20","ProofOfResidence":"House","Name":"Jess","Phone":"081915543390","Relationship":"Cousin"}
 static Future<ProfileModel> getprofile({String email, String idUser, String url}) async  {
    var uri = Uri(
      scheme: 'http',
      host: '192.168.0.16',
      path: 'edufund-api/Api/getprofileaccountbyemail.php',
      queryParameters: {
        'email': [email],
      },
    );
    print(uri);
    final response = await http.get(uri,headers:{"Content-Type":
    "application/json"},
    );
    var res = ProfileModel.fromJson(jsonDecode(response.body)[0]);
    print(response.body);
    return res;
  }