1

I have an issue while writing my code in the main page of my app i'm requesting a get from my json file and receiving a list of users + their info and when tapped on each of these users a new page opens up with some additional information. in the 2nd page i make a new get request and this is where the problem happens and I get this error: The following NoSuchMethodError was thrown building FutureBuilder(dirty, state: _FutureBuilderState get http and my widget.data. returns as null some help would be appreciated.

try {
String url =
'http://10.0.0.21:8000/api/users/' + widget.employee.id.toString();
individualData = await http.get(Uri.parse(url));

var test = individualData;
} catch (e) {
print(e.toString());
}

2 Answers 2

1

i forgot to put an if else to check if data exists

Sign up to request clarification or add additional context in comments.

2 Comments

Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.
Thanks, would you please add some code snippets and explain why that code snippets solve the problem?
1
String? employeeId = widget.employee.id;

if(employeeId!=null){
try {
String url =
'http://10.0.0.21:8000/api/users/' + employeeId;
individualData = await http.get(Uri.parse(url));

var test = individualData;
} catch (e) {
print(e.toString());
}
}else{
    print('Getting employeeId as null');
}

So first check employeeId is not getting a null and then call a API.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.