简体   繁体   中英

Flutter: Unhandled Exception: type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'String'

I'm using Dio Package to send requests to my backend, which send me back the response as Json, but when I try to parse it using jsonDecode I get error saying:

Unhandled Exception: type '_InternalLinkedHashMap<String, dynamic>' is not a subtype of type 'String'

Here is my code:

 Response response = await Dio().post(
              'http://192.168.43.139:8000/api/login',
              data: {"phone": phoneNum, "password": password});

          Map jsonData = jsonDecode(response.data);
          print(jsonData);

anyone know how to solve this problem ?

You can use var jsonData = jsonDecode(response.data); This will bypass the error.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM