http请求后拿到的数据中文是乱码如何解决呢
来源:9-2 基于Http实现网络操作
慕无忌7464875
2019-03-27
写回答
1回答
-
CrazyCodeBoy
2019-03-27
在课程中有讲解哦,可参考:https://git.imooc.com/coding-321/flutter_trip/src/master/lib/dao/home_dao.dart:
///首页大接口 class HomeDao { static Future<HomeModel> fetch() async { final response = await http.get(HOME_URL); if (response.statusCode == 200) { Utf8Decoder utf8decoder = Utf8Decoder(); // fix 中文乱码 var result = json.decode(utf8decoder.convert(response.bodyBytes)); return HomeModel.fromJson(result); } else { throw Exception('Failed to load home_page.json'); } } }
00
相似问题