title: How to access an item from a json through FutureBuilder?
body: <p>i'm getting a json and would like to access certain items.</p>
  <p>The method below returns the json I need to access.</p>
  <pre><code>search(cpf) async {
      try {
        final response = await http.get(
            Uri.parse(BaseUrl.baseUrl + 'api/produtor/serach/$data'));
        if (response.statusCode == 200) {
          final jsonMap = jsonDecode(response.body) as Map&lt;String, dynamic&gt;;
          final user = User.fromJson(jsonMap);
          return user;
        } else {
          throw Exception(&quot;Error&quot;);
        }
      } catch (e) {
        throw Exception(e.toString());
      }
    }
  </code></pre>
  <p>I created this example to try to access the items.</p>
  <pre><code>Future? _list;
  
    @override
    void initState() {
      super.initState();
      _list = widget.produtorServices.buscaProdutorPorCPF(&quot;56039891653&quot;);
    }
  
   Widget build(BuildContext context) {
      return new Scaffold(
        body: Container(
          child: FutureBuilder(
            future: widget.produtorServices.buscaProdutorPorCPF(&quot;56039891653&quot;),
            builder: (BuildContext context, AsyncSnapshot snapshot) {
              if (snapshot.connectionState != ConnectionState.done) {
                return const Center(child: CircularProgressIndicator());
              }
              if (snapshot.hasError) {
                return Text(&quot;${snapshot.error}&quot;);
              }
              if (!snapshot.hasData) {
                return Text(&quot;Null returned&quot;);
              }
              final user = snapshot.data as Produtor;
              return Column(
                mainAxisAlignment: MainAxisAlignment.center,
                children: [
                  Text('${user.id}: ${user.name}'),
                ],
              ); //Text(snapshot.data!.ip);
            },
          ),
        ),
      );
    }
  }
  
  </code></pre>
  <p>Here is json</p>
  <pre><code>[
     {
        &quot;user&quot;:{
           &quot;roles&quot;:[
              &quot;622f533b5ee724631428f469&quot;
           ],
           &quot;_id&quot;:&quot;622f78fbf297571510cb4e32&quot;,
           &quot;nome&quot;:&quot;XXXX&quot;,
           &quot;email&quot;:&quot;teste@teste.com&quot;
        }
     }
  ]
  </code></pre>
  <p><strong>How do I add eg a text widget and access the json item?</strong></p>
  <p>I've already tried to solve using the model too. I declare <strong>User user</strong> and then I try to access the variable like this: <strong>user.name</strong></p>
  <p>But I get the error:</p>
  <blockquote>
  <p>Error: Exception: Expected a value of type 'Map&lt;String, dynamic&gt;', but got one of type 'List'</p>
  </blockquote>
  <p>I appreciate if anyone can help me analyze this!</p>