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
相关推荐
抓饼先生17 分钟前
Linux control group笔记
linux·笔记·bash
吃饭最爱22 分钟前
html的基础知识
前端·html
我没想到原来他们都是一堆坏人23 分钟前
(未完待续...)如何编写一个用于构建python web项目镜像的dockerfile文件
java·前端·python
挺6的还38 分钟前
25.线程概念和控制(二)
linux
前端Hardy44 分钟前
HTML&CSS:有趣的漂流瓶
前端·javascript·css
前端Hardy1 小时前
HTML&CSS :惊艳 UI 必备!卡片堆叠动画
前端·javascript·css
您的通讯录好友1 小时前
conda环境导出
linux·windows·conda
无羡仙1 小时前
替代 Object.freeze 的精准只读模式
前端·javascript
web前端1231 小时前
Java客户端开发指南 - 与Web开发对比分析
前端
龙在天1 小时前
前端 9大 设计模式
前端