Skip to content
Advertisement

type ‘_InternalLinkedHashMap’ is not a subtype of type ‘FutureOr<List>’

I have a Problem with my json.decode. I want to get some data from my website but when my website says {“Number”:5} i only get this error (type ‘_InternalLinkedHashMap<String, dynamic>’ is not a subtype of type ‘FutureOr<List>’).

However if my website says string{“Number”:5} i get the correct output and this error FormatException: Unexpected character (at character 1).

Here is my Flutter code:

@override
void initState() {


Future<List> senddata() async {
  final response = await http.post("http://www.quyre.de/2/Home.N.php", body: {
    "status": "0",
    "nam_ersteller": "Quyre",
  });

  var datauser = json.decode(response.body);
  return datauser;
}

senddata();
}

Thanks for any answer

Advertisement

Answer

Your data from the website and receive by datauser is a Map, not a List.

Change this

Future<List> senddata() async

For this:

Future<Map<String, dynamic>> senddata() async
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement