Flutter 笔记

  • Flutter需要重点掌握的内容:InheritWidget、FutureBuilder、Provider、Listener
  • Flutter Android Emulator 使用VScode启动过程长时间无响应,运行flutter clean清除运行缓存后即可!
  • 在没有使用Scaffold时,为了让子元素拥有基本的样式,可以使用Material Design默认样式风格,直接使用Material作为根组件即可!
  • *Noted* This class (or a class which this class inherits from) is marked as '@immutable', but one or more of its instance fields are not final
  • 以上警告是因为StatelessWidget是一个不可变的Widget,所以需要声明final。
  • *Noted* Got socket error trying to find package at http://pub.dartlang.org
  • 出现以上错误需要换pub库地址
  • Mac执行 export PUB_HOSTED_URL=https://pub.flutter-io.cn export FLUTTER_STORAGE_BASE_URL=https://storage.flutter-io.cn
  • *Noted* Error caught by rendering library, thrown during performResize()。Vertical viewport was given unbounded height ...
  • 此错误是因为ListView高度边界无法确定影响的,解决方法为给ListView指定边界,例如使用SizedBox或Flex、Expanded拉伸布局。
  • Waiting for another flutter command to release the startup lock...
  • 关闭模拟器退出编辑程序,打开flutter安装目录/bin/cache,删除lockfile文件。
  • ListTile 单独使用会NotFound,目前已记录在AppBar内部可以正常使用。
  • *Noted* Vertical viewport was given unbounded height. If this widget is always nested in a scrollable widget there is no need to use a viewport because there will always be enough vertical space for the children. In this case, consider using a Column instead. Otherwise, consider using the "shrinkWrap" property (or a ShrinkWrappingViewport) to size the height of the viewport to the sum of the heights of its children.
  • 需要设置shrinkWrap = true,表示是否根据子组件的总长度设置ListView的长度,默认为false,当它在无边界的容器中时,必须设为true
  • *Noted* A comparison expression can't be an operand of another comparison expression. Try putting parentheses around one of the comparisons.
  • 一个比较表达式不能是另一个比较表达式的操作数。(Dart基础语法错误,把花括号改为圆括号即可)
posted @ 2020-10-09 22:37  universe-cosmo  阅读(228)  评论(0编辑  收藏  举报