简体   繁体   中英

Flutter json response using Dio

I have a simple response.data that get me {message: You have checked in successfully}

var dio = Dio();
Response response = await dio.get('http://10.0.2.2:4000/');
print(response.data); //{message: You have checked in successfully}

How can I just print out: You have checked in successfully? Using print(response.data.message) will not work.

Convert your response.data to Map using the below Code,

 Map result = response.data;
 print(result['message']);

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