Flutter问题合集

一、json解析中文乱码

引入依赖:

import 'dart:convert';
import 'package:http/http.dart' as http;
response是网络请求返回内容
jsonDecode(Utf8Decoder().convert(response.bodyBytes))

参考链接:

https://blog.csdn.net/cf01201003/article/details/83868307

其余参考代码:

/// rootBundle.loadString源码修改
Future<String> _loadString(String key) async {
  final ByteData data = await rootBundle.load(key);
  if (data == null) {
    throw FlutterError('Unable to load asset: $key');
  }
  return utf8.decode(data.buffer.asUint8List());
}
二、引用第三方.so库

报错如下:

If you're running an application and need to access the binary messenger bef....

解决办法如下:

void main() {
  WidgetsFlutterBinding.ensureInitialized();//集成第三方.so的时候需要提前在这里进行初始化这行代码
  runApp(MyApp());
}
三、Gradle build failed to produce an .apk file. It‘s likely that this file was generated under XXX

解决办法如下:

https://blog.csdn.net/a644388262/article/details/107973600

四、Flutter 定义product flavors

错误如下:

The Gradle project does not define a task suitable for the requested build.

The android/app/build.gradle file defines product flavors: huawei

You must specify a --flavor option to select one of them.

Finished with error: Gradle build aborted.

参考下面链接进行解决:

https://www.cnblogs.com/dhui69/p/11356728.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值