'NoSuchMethodError Flutter

Help me please... I tried to solve this problem since some days but nothing worked T.T

I don't understand what is null or [] ... The json I received is OK

My function to get data

  Future<dynamic> getTypeTemps() async {
    var res = await http.post(Uri.parse(TTurl + "?action=LST"));
    if (res.statusCode == 200) {
      setState(() {
        TTdata = json.decode(res.body);
      });
    } else {
      setState(() {error = true; message = "Erreur avec la table TypeTemps";});
    }   }

getTypeTemps is called in void initstate()

The widget to show the list

Widget WdgListTT() {
    List<TypesTemps> ttlist = List<TypesTemps>.from(
        TTdata["TTdata"].map((i){
          return TypesTemps.fromJSON(i);
        })
    ); //searilize typetemps json data to object model.
    return Column(children: [
      const Padding(
        padding: EdgeInsets.only(bottom: 20),
      ),
      SizedBox(
        width: MediaQuery.of(context).size.width - 40,
        child: const Text("Type de temps", style: TextStyle(color: Colors.teal, fontWeight: FontWeight.bold, fontSize: 18),),
      ),
      SizedBox(
          width: MediaQuery.of(context).size.width - 50,
          child: DropdownButtonHideUnderline(
              child: DropdownButton<String>(
                //style: const TextStyle(color: Colors.white),
                value: valtypetemps,
                onChanged: (value) => setState(() => valtypetemps = value),
                elevation: 20,
                underline: Container(
                  height: 10,
                  color: Colors.red,
                ),
                hint: const Text("Sélectionnez un type",
                    style: TextStyle(fontSize: 16)),
                isExpanded: true,
                items: ttlist.map((typesTemps) {
                  return DropdownMenuItem(
                    child: Text(typesTemps.libelle,
                        style: TextStyle(color: Colors.black)),
                    value: typesTemps.libelle,
                  );
                }).toList(),
              )))
    ]);   }

The class

class TypesTemps {   String code, libelle, type_temps;   TypesTemps({
    required this.code,
    required this.libelle,
    required this.type_temps,   });   factory TypesTemps.fromJSON(Map json) {
    return TypesTemps(
        code: json["CODE"],
        libelle: json["LIBELLE"],
        type_temps: json["SENS_TYPE_TEMPS"]);   } }


Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source