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 分钟前
案例-任务清单
前端·javascript·css
C++忠实粉丝33 分钟前
Linux环境基础开发工具使用(2)
linux·运维·服务器
康熙38bdc1 小时前
Linux 环境变量
linux·运维·服务器
zqx_71 小时前
随记 前端框架React的初步认识
前端·react.js·前端框架
惜.己2 小时前
javaScript基础(8个案例+代码+效果图)
开发语言·前端·javascript·vscode·css3·html5
hakesashou2 小时前
python如何比较字符串
linux·开发语言·python
什么鬼昵称2 小时前
Pikachu-csrf-CSRF(get)
前端·csrf
Ljubim.te2 小时前
Linux基于CentOS学习【进程状态】【进程优先级】【调度与切换】【进程挂起】【进程饥饿】
linux·学习·centos
cooldream20092 小时前
Linux性能调优技巧
linux
长天一色2 小时前
【ECMAScript 从入门到进阶教程】第三部分:高级主题(高级函数与范式,元编程,正则表达式,性能优化)
服务器·开发语言·前端·javascript·性能优化·ecmascript