Flutter print only one value from response

My response return:

print(response.body);

I/flutter (31140): {"code":99,"email":"mail@mail.com"}

How print only code or email

I/flutter (31140): {"code":99}

>Solution :

I think you can use jsonDecode function from dart:convert library

import 'dart:convert';
Map<String, dynamic> myResponse= jsonDecode(response.body);
print('Code: ${myResponse['code']}  Email: ${myResponse['email']} ');
 

Leave a Reply