flutter报错

组件相关

  1. type 'List' is not a subtype of type 'List'

children: CardList.map((item) => Container( 加上 *** < Widget>*** 正常

  1. type '(dynamic, dynamic) => Container' is not a subtype of type '(CardType) => Widget' of 'f'
flutter 复制代码
 children: CardList.map<Widget>((item, index) => Container(

正确使用 map 的索引值应该加上 .asMap().entries.map 转化为实例,key/value形式

flutter 复制代码
children: CardList.asMap()
.entries
.map<Widget>((item) => Container(
  width: (MediaQuery.of(context).size.width -
          (JwSizes.width30 * 5)) /
      4,
  child: GestureDetector(
      onTap: () => checkCard(item.key),
      child: Column(
        children: [
          Image.asset(
            item.value.image,
            height: JwSizes.width32,
            fit: BoxFit.fitWidth,
          ),
          SizedBox(height: JwSizes.height6),
          Text(item.value.title, style: common13TextStyle)
        ],
      )),
))
.toList(),
  1. flutter GestureDetector 点击无效 手势冲突

GestureDetector 内嵌套 chart图表,希望点击后跳转,却展示 图表tootip 没有跳转

https://book.flutterchina.club/chapter8/gesture_conflict.html#_8-4-5-解决手势冲突

dart 复制代码
// 使用 Listener 替代 GestureDetector 
 Listener(
                  // TODO 点击跳转无效,被子组件影响
                  behavior: HitTestBehavior.opaque,
                  onPointerUp: (PointerUpEvent event) {
                    controller.gotoGroup(item.value);
                  }
  1. flutter 唤起键盘 OverlayEntry状态丢失

OverlayEntry中包含 输入框,每当唤起键盘后,OverlayEntry属性mounted 改为了 false 无法remove掉

复制代码
解决 在 事件 onPressed 中将页面中定义的具体组件赋值给 状态控制器中定义的 OverlayEntry overlayEntry,
防止 键盘唤起后,状态丢失。

连接设备相关

  1. 连接不到设备
  2. flutter docker > Unable to run "adb", check your Android SDK installation and ANDROID_SDK_ROOT environment variable:
    adb.exe 23288 23684 fdevent_poll.cpp:64] failed to create f
    • 打开控制面板->防火墙->允许应用通过Windows防火墙
    • 允许的应用界面:先点击 更改设置按钮→再点击允许其他应用按钮
    • 选择添加允许的应用(adb.exe)

运行相关

  1. Could not connect to the Gradle daemon.
    Daemon uid: 36b1cf53-4fc6-450a-9f6d-5feea276380b with diagnostics:
    Daemon pid: 16588
  • 重新安装 flutter
  • 关闭防火墙

框架功能使用相关

  1. 设置横竖屏,出现闪烁

原因: 页面横竖屏切换需要一定时间,同时触发了页面更新

flutter 复制代码
Future<bool> zoomChart({bool? flag}) async {
    isZoom.value = flag ?? !isZoom.value;
    if (isZoom.value) {
      await SystemChrome.setPreferredOrientations([
        DeviceOrientation.landscapeLeft,
        DeviceOrientation.landscapeRight,
      ]);
    } else {
      await SystemChrome.setPreferredOrientations([
        DeviceOrientation.portraitUp,
        DeviceOrientation.portraitDown,
      ]);
    }
    update();
    return true;
  }
  1. removeInvalidNode all the node in jank list is out of time
相关推荐
树上有只程序猿8 分钟前
终于有人把数据库讲明白了
前端
猩兵哥哥13 分钟前
前端面向对象设计原则运用 - 策略模式
前端·javascript·vue.js
司宸14 分钟前
Prompt设计实战指南:三大模板与进阶技巧
前端
RoyLin16 分钟前
TypeScript设计模式:抽象工厂模式
前端·后端·typescript
华仔啊21 分钟前
Vue3+CSS 实现的 3D 卡片动画,让你的网页瞬间高大上
前端·css
江城开朗的豌豆30 分钟前
解密React虚拟DOM:我的高效渲染秘诀 🚀
前端·javascript·react.js
vivo互联网技术38 分钟前
拥抱新一代 Web 3D 引擎,Three.js 项目快速升级 Galacean 指南
前端·three.js
江城开朗的豌豆1 小时前
React应用优化指南:让我的项目性能“起飞”✨
前端·javascript·react.js
会飞的青蛙1 小时前
GIT 配置别名&脚本自动化执行
前端·git