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
相关推荐
小小小小宇5 小时前
虚拟列表兼容老DOM操作
前端
悦悦子a啊5 小时前
Python之--基本知识
开发语言·前端·python
2401_826097626 小时前
JavaEE-Linux环境部署
java·linux·java-ee
安全系统学习6 小时前
系统安全之大模型案例分析
前端·安全·web安全·网络安全·xss
涛哥码咖6 小时前
chrome安装AXURE插件后无效
前端·chrome·axure
OEC小胖胖7 小时前
告别 undefined is not a function:TypeScript 前端开发优势与实践指南
前端·javascript·typescript·web
(:满天星:)7 小时前
第31篇:块设备与字符设备管理深度解析(基于OpenEuler 24.03)
linux·运维·服务器·网络·centos
行云&流水7 小时前
Vue3 Lifecycle Hooks
前端·javascript·vue.js
爱莉希雅&&&7 小时前
shell编程之awk命令详解
linux·服务器·git
笑稀了的野生俊7 小时前
在服务器中下载 HuggingFace 模型:终极指南
linux·服务器·python·bash·gpu算力