文章目录
一、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