Daryl Wong
Daryl Wong

Reputation: 2443

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.

Upvotes: 0

Views: 2371

Answers (1)

Mukul
Mukul

Reputation: 1155

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

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

Upvotes: 1

Related Questions