解决方案

Waiting for another flutter command to release the startup lock…

解决办法:

  1. 打开任务管理器,看看有没有Dart.exe运行着,有的话全部结束了,然后重启试试
  2. 还是不行的话就删除掉 flutter\bin\cache 目录下的 lockfile 文件

Error connecting to the service protocol

错误详情:

Error connecting to the service protocol: HttpException: Connection closed before full header was received

解决方案:

可能是模拟器API版本太高, 之前用了 API 为 Q 的模拟器, 换成 API 为 24 的就解决了

flutter_swiper 的问题

错误信息:

══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (21956): The following assertion was thrown building NotificationListener:
I/flutter (21956): ScrollController not attached to any scroll views.
I/flutter (21956): 'package:flutter/src/widgets/scroll_controller.dart': Failed assertion: line 110 pos 12:
I/flutter (21956): '_positions.isNotEmpty'
I/flutter (21956):
I/flutter (21956): Either the assertion indicates an error in the framework itself, or we should provide substantially

解决方案: 给 flutter_swiper 设置 key: ValueKey(items.length)

Swiper(
  key: ValueKey(carouselList.length),
  itemBuilder: (BuildContext context,int index){
    return new Image.network(carouselList[index],fit: BoxFit.fill,);
  },
  itemCount: carouselList.length,
  pagination: new SwiperPagination(),
),

参考: swiper item can't be hot add?

Entry point isn't within current project

解决方式:在 Android Studio 中找到 File -> Project Structure -> Module 然后添加项目的根文件夹,然后它将再次检测到它是一个flutter的应用程序,然后再次构建和工作。

参考: Flutter 集成到Android项目中遇到的坑

MediaQuery.of() called with a context that does not contain a MediaQuery

解决方案:想让界面跑起来,需要 runApp(),需要再写个 MyApp() 里面使用 MaterialApp() 包裹写好的界面,这样才可以运行。

参考: Flutter: MediaQuery.of() called with a context that does not contain a MediaQuery

参考

MIT Licensed | Copyright © 2018-present 滇ICP备16006294号

Design by Quanzaiyu | Power by VuePress