Flutter学习中遇到的小问题记录

  1. Error connecting to the service protocol: HttpException: , uri = http://127.0.0.1:1026/n7mjQdqNp7w=/ws Exited (sigterm)

在iOS真机上使用报的这个错误,通过重新连接设备,重启Xcode编译器解决了

  1. Comments are not permitted in JSON.
    删除json文件后的注释就OK了。

  2. A dependency may only have one source。


    屏幕快照 2019-08-29 上午10.31.40.png

这个是因为在导入package包的时候没注意对齐,对比两张图片就明白了。
屏幕快照 2019-08-29 上午10.36.00.png

4.flutter: DioError [DioErrorType.DEFAULT]: HandshakeException: Handshake error in client (OS Error:
CERTIFICATE_VERIFY_FAILED: ok(handshake.cc:354))
https证书问题

  1. flutter: Another exception was thrown: A GlobalKey was used multiple times inside one widget's child list.
    关闭重新运行一下就好了....

6.TabController在创建时vsync使用this一直报错,需要添加with SingleTickerProviderStateMixin

7.解决iOS真机运行 Cloning into '/var/folders/z3/jxqy5rh52xxgs0j_7l6lzfl00000gn/T/d20200509-21922-5mfy8x'...
fatal: unable to access 'https://github.com/webmproject/libwebp.git/': Failed to connect to 127.0.0.1
port 53783: Connection refused

解决方法:1、pod repo 查看 cocoapods 在本机的PATH(可能存在多个分支)
2.前往文件夹 (⇧⌘G) -> ~/.cocoapods/repos/master/Specs/1/9/2/libwebp
3.将json中source下git地址更改为https://github.com/webmproject/libwebp.git

8.# Engine run configuration was invalid

flutter channel master
flutter upgrade

9.使用FutureBuilder是snapshot的data的数据一直是空值

future 方法里一定要进行return。return空字符串也行

10.Flutter ServicesBinding.defaultBinaryMessenger was accessed before the binding was initialized.
在使用shared_preferences初始化的时候

void main() {
  WidgetsFlutterBinding.ensureInitialized();
  runApp(MyApp());
}

11.Flutter 使用Dio请求返回数据不是Json字符串,而是Json对象

responseType: ResponseType.plain,

12.[!] The 'Pods-Runner' target has transitive dependencies that include statically linked binaries: (/Users/wanggang/Desktop/hushishangmen/hushishangmen/ios/Pods/BMKLocationKit/framework/BMKLocationKit.framework)

引入百度地图,pod install 时报错
image

解决:
第一种:删除ios项目中podfile中的 use_frameworks!

或者第二种:BMKLocationKit,这个百度地图里新增如下代码

image

你可能感兴趣的:(Flutter学习中遇到的小问题记录)