title: Get a single model from server using HTTP in flutter
body: <p>I would like to retrieve the information of a <strong>single</strong> user from a response sent by a server.</p>
  <p><strong>Get the response :</strong></p>
  <pre><code>import 'dart:convert';
  
  import 'package:flutter_project/model/user_model.dart';
  import 'package:http/http.dart' show get;
  
  class PhpUser
  {
    PhpUser();
  
  
    Future&lt;List&lt;UserModel&gt;&gt; downloadJson() async
    {
      const url = &quot;http://10.0.2.2/TeamMateProject/php/scripts/scriptUser.php&quot;;
      final response = await get(Uri.parse(url));
      if(response.statusCode==200)
        {
          List jsonResponse = json.decode(response.body);
          return jsonResponse.map((e) =&gt; UserModel.fromMap(e)).toList();
        }
      else
        {
          throw Exception(response.body);
        }
  
    }
  }
  </code></pre>
  <p>I already try to return <code>Future&lt;UserModel&gt;</code> instead of <code>Future&lt;List&lt;UserModel&gt;&gt;</code></p>
  <p><strong>Here is how I try to find the user :</strong></p>
  <pre><code>FutureBuilder(
        future: PhpUser().downloadJson(),
        builder: (context, snapshot){
          UserModel userModel = snapshot.data as UserModel;
          return ProfileScreen(userModel);
        })
  </code></pre>
  <p><strong>The UserModel :</strong></p>
  <pre><code>class UserModel
  {
    int idUser;
    String emailUser;
    String pseudoUser;
    String passwordUser;
    String imageUser;
    bool statusUser;
    String lastTimeConnectionUser;
  
    ///Constructor of the class
    UserModel({ required this.idUser, required this.emailUser, required this.pseudoUser, required this.passwordUser,
      required this.imageUser, required this.statusUser, required this.lastTimeConnectionUser});
  
  
  
    Map&lt;String, dynamic&gt; toMap()
    {
      return {
        'idUser': idUser,
        'emailUser': emailUser,
        'pseudoUser': pseudoUser,
        'passwordUser' :passwordUser,
        'imageUser': imageUser,
        'statusUser': statusUser,
        'lastTimeConnectionUser': lastTimeConnectionUser,
      };
    }
  
    ///Function to create a UserModel with Json data
    factory UserModel.fromMap(Map&lt;String, dynamic&gt; map) =&gt; UserModel(
        idUser : map['idUser'],
        emailUser : map['emailUser'],
        pseudoUser : map['pseudoUser'],
        passwordUser : map['passwordUser'],
        imageUser : map['imageUser'],
        statusUser : map['statusUser'] == 1,
        lastTimeConnectionUser : map['lastTimeConnectionUser']
    );
  }
  </code></pre>
  <p><strong>Here is the response.body :</strong> [{&quot;lastTimeConnectionUser&quot;:&quot;2002-02-02 10:00:00&quot;},{&quot;statusUser&quot;:0},{&quot;imageUser&quot;:&quot;toto.png&quot;},{&quot;passwordUser&quot;:&quot;toto&quot;},{&quot;pseudoUser&quot;:&quot;Toto&quot;},{&quot;emailUser&quot;:&quot;test@gmail.com&quot;},{&quot;idUser&quot;:1}]</p>
  <p>Of course the UserModel is null, I know I made a mistake but I don't see how to do otherwise</p>