0

I have this app which prints the list of data which I got from my test database - Users table [{id: 2147483647, email: [email protected], password: test12, username: User}] so I want to save the id, email, ..... in vars how ? also new to flutter :) edit: this is the function that I call in initState:

void fetchData() async {
    final response = await http.get('http://192.168.137.1/fetch_data.php');
    if (response.statusCode == 200) {
      setState(() {
        data = json.decode(response.body);
      });
      print(data);
    }
  }

1 Answer 1

1

In your code data is List<Map<String,dynamic>> so for example to print all usernames you can do something like this:

data.forEach((item) { 
  print(item['username']);
});
Sign up to request clarification or add additional context in comments.

3 Comments

But I have another question Can I search in the given data ?
As I want to do login.
@omardeveloper yes its not hard. just loop through the list and find the key on map

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.