flutter报错Cannot hit test a render box that has never been laid out

news2024/11/16 4:21:09

出现这个问题的原因可能是因为你把一个ListView或者GridView放到了一个没有设置大小的容器里面导致的,所以意思是不能渲染那一个没有布局过的容器。我这里遇到的错误是因为我把GridView放到了一个Container里面,并且我没有设置Container宽高。

就导致了那个错误:

======== Exception caught by gestures library ======================================================
The following assertion was thrown while handling a pointer data packet:
Cannot hit test a render box that has never been laid out.

The hitTest() method was called on this RenderBox: RenderStack#349bb NEEDS-LAYOUT NEEDS-PAINT
...  parentData: offset=Offset(0.0, 0.0); id=_ScaffoldSlot.floatingActionButton
...  constraints: MISSING
...  size: MISSING
...  alignment: Alignment.centerRight
...  textDirection: ltr
...  fit: loose
Unfortunately, this object's geometry is not known at this time, probably because it has never been laid out. This means it cannot be accurately hit-tested.

If you are trying to perform a hit test during the layout phase itself, make sure you only hit test nodes that have completed layout (e.g. the node's children, after their layout() method has been called).

When the exception was thrown, this was the stack: 
#0      RenderBox.hitTest.<anonymous closure> (package:flutter/src/rendering/box.dart:2442:11)
#1      RenderBox.hitTest (package:flutter/src/rendering/box.dart:2473:6)
#2      RenderBoxContainerDefaultsMixin.defaultHitTestChildren.<anonymous closure> (package:flutter/src/rendering/box.dart:2854:25)
#3      BoxHitTestResult.addWithPaintOffset (package:flutter/src/rendering/box.dart:800:31)
#4      RenderBoxContainerDefaultsMixin.defaultHitTestChildren (package:flutter/src/rendering/box.dart:2849:33)
#5      RenderCustomMultiChildLayoutBox.hitTestChildren (package:flutter/src/rendering/custom_layout.dart:415:12)
#6      RenderBox.hitTest (package:flutter/src/rendering/box.dart:2475:11)
#7      RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:117:19)
#8      RenderBox.hitTest (package:flutter/src/rendering/box.dart:2475:11)
#9      RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:117:19)
#10     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2475:11)
#11     RenderPhysicalModel.hitTest (package:flutter/src/rendering/proxy_box.dart:1990:18)
#12     RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:117:19)
#13     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2475:11)
#14     RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:117:19)
#15     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2475:11)
#16     RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:117:19)
#17     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2475:11)
#18     RenderIgnorePointer.hitTest (package:flutter/src/rendering/proxy_box.dart:3609:31)
#19     RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:117:19)
#20     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2475:11)
#21     RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:117:19)
#22     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2475:11)
#23     RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:117:19)
#24     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2475:11)
#25     RenderOffstage.hitTest (package:flutter/src/rendering/proxy_box.dart:3738:31)
#26     RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:117:19)
#27     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2475:11)
#28     _RenderTheaterMixin.hitTestChildren.childHitTest (package:flutter/src/widgets/overlay.dart:856:81)
#29     BoxHitTestResult.addWithPaintOffset (package:flutter/src/rendering/box.dart:800:31)
#30     _RenderTheaterMixin.hitTestChildren (package:flutter/src/widgets/overlay.dart:857:22)
#31     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2475:11)
#32     RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:117:19)
#33     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2475:11)
#34     RenderAbsorbPointer.hitTest (package:flutter/src/rendering/proxy_box.dart:3856:17)
#35     RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:117:19)
#36     RenderProxyBoxWithHitTestBehavior.hitTest (package:flutter/src/rendering/proxy_box.dart:172:19)
#37     RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:117:19)
#38     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2475:11)
#39     RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:117:19)
#40     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2475:11)
#41     RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:117:19)
#42     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2475:11)
#43     RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:117:19)
#44     RenderTapRegionSurface.hitTest (package:flutter/src/widgets/tap_region.dart:213:28)
#45     RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:117:19)
#46     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2475:11)
#47     RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:117:19)
#48     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2475:11)
#49     RenderProxyBoxMixin.hitTestChildren (package:flutter/src/rendering/proxy_box.dart:117:19)
#50     RenderBox.hitTest (package:flutter/src/rendering/box.dart:2475:11)
#51     RenderView.hitTest (package:flutter/src/rendering/view.dart:194:14)
#52     RendererBinding.hitTestInView (package:flutter/src/rendering/binding.dart:534:16)
#53     GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:384:7)
#54     GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:376:5)
#55     GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:323:7)
#56     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:292:9)
#57     _invoke1 (dart:ui/hooks.dart:186:13)
#58     PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:424:7)
#59     _dispatchPointerDataPacket (dart:ui/hooks.dart:119:31)
====================================================================================================

======== Exception caught by gestures library ======================================================
The following assertion was thrown while handling a pointer data packet:
'package:flutter/src/rendering/mouse_tracker.dart': Failed assertion: line 205 pos 12: '!_debugDuringDeviceUpdate': is not true.


Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=2_bug.yml

When the exception was thrown, this was the stack: 
#2      MouseTracker._deviceUpdatePhase (package:flutter/src/rendering/mouse_tracker.dart:205:12)
#3      MouseTracker.updateWithEvent.<anonymous closure> (package:flutter/src/rendering/mouse_tracker.dart:328:7)
#4      MouseTracker._monitorMouseConnection (package:flutter/src/rendering/mouse_tracker.dart:193:9)
#5      MouseTracker.updateWithEvent (package:flutter/src/rendering/mouse_tracker.dart:327:5)
#6      RendererBinding.dispatchEvent (package:flutter/src/rendering/binding.dart:326:20)
#7      GestureBinding._handlePointerEventImmediately (package:flutter/src/gestures/binding.dart:413:7)
#8      GestureBinding.handlePointerEvent (package:flutter/src/gestures/binding.dart:376:5)
#9      GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:323:7)
#10     GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:292:9)
#11     _invoke1 (dart:ui/hooks.dart:186:13)
#12     PlatformDispatcher._dispatchPointerDataPacket (dart:ui/platform_dispatcher.dart:424:7)
#13     _dispatchPointerDataPacket (dart:ui/hooks.dart:119:31)
(elided 2 frames from class _AssertionError)

 所以添加一个宽高就好了:

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1390947.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

linux如何排查cpu持续飙高原因

一、检查CPU使用率 首先在Linux系统中检查CPU使用率。可以通过在命令行中输入top或htop命令来查看当前系统中各个进程的CPU使用率。如果CPU使用率大于80%&#xff0c;则可以考虑进行排查。 $ top二、检查系统负载 另外可以使用uptime命令来查看系统的平均负载情况。 $ upti…

elasticsearch6.6.0设置访问密码

elasticsearch6.6.0设置访问密码 第一步 x-pack-core-6.6.0.jar第二步 elasticsearch.yml第三步 设置密码 第一步 x-pack-core-6.6.0.jar 首先破解 x-pack-core-6.6.0.jar 破解的方式大家可以参考 https://codeantenna.com/a/YDks83ZHjd 中<5.破解x-pack> 这部分 , 也可…

Zookeeper安装教程

文章目录 前言一、选择安装包二、使用wget下载并安装zookeeper 前言 Linux下Zookeeper安装步骤 一、选择安装包 Zookeeper下载地址&#xff1a;https://zookeeper.apache.org/releases.html 选择一个稳定版本即可&#xff0c;我这里选择的是3.7.2 点击“Apache ZooKeeper 3.…

考研C语言刷题篇之分支循环结构一

目录 第一题 第二题 方法一&#xff1a;要循环两次&#xff0c;一次求阶乘&#xff0c;一次求和。 注意&#xff1a;在求和时&#xff0c;如果不将sum每次求和的初始值置为1&#xff0c;那么求和就会重复。 方法二&#xff1a; 第三题 方法一&#xff1a;用数组遍历的思想…

Spring高手之路-Spring事务失效的场景详解

目录 前言 Transactional 应用在非 public 修饰的方法上 同一个类中方法调用&#xff0c;导致Transactional失效 final、static方法 Transactional的用法不对 Transactional 注解属性 propagation 设置不当 Transactional注解属性 rollbackFor 设置错误 用错注解 异常…

实战whisper:本地化部署通用语音识别模型

前言 Whisper 是一种通用语音识别模型。它是在大量不同音频数据集上进行训练的&#xff0c;也是一个多任务模型&#xff0c;可以执行多语言语音识别、语音翻译和语言识别。 这里呢&#xff0c;我将给出我的一些代码&#xff0c;来帮助你尽快实现【语音转文字】的服务部署。 以下…

最佳实践分享:SQL性能调优

SQL性能调优是一个需要不断探索和实践的过程&#xff0c;旨在确保数据库查询的高效运行。本文将分享一些SQL性能调优的最佳实践&#xff0c;帮助您提升数据库性能&#xff0c;减少查询响应时间。 一、索引优化 索引是提高查询性能的关键。以下是一些关于索引优化的建议&#…

使用micro-app将现有项目改造成微前端,对现有项目实现增量升级

使用micro-app将现有项目改造成微前端&#xff0c;对现有项目实现增量升级 基座应用 1、安装依赖 npm i micro-zoe/micro-app --save2、在入口引入 //main.js import microApp from micro-zoe/micro-appnew Vue({ }) //在new Vue 下面执行 microApp.start()3、新增一个vue页…

ASP.NET Core 的 Web Api 实现限流 中间件

Microsoft.AspNetCore.RateLimiting 中间件提供速率限制&#xff08;限流&#xff09;中间件。 它是.NET 7 以上版本才支持的中间件&#xff0c;刚看了一下&#xff0c;确实挺好用&#xff0c;下面给大家简单介绍一下&#xff1a; RateLimiterOptionsExtensions 类提供下列用…

5 个被低估的开源项目

文章目录 1.集算器 -数据处理2. Firecamp - 邮递员替代方案3.Keploy——后端 测试4. Hanko - 密钥验证5. Zrok - Ngrok 类固醇 长话短说 本文列出了五个不太受欢迎的优秀项目&#xff0c;您应该尝试一下。&#x1f525; 这些工具旨在改进数据处理、API 开发、后端测试、身份验…

MiniTab的拟合回归模型的系列参数设置

为拟合回归模型指定模型项 统计 > 回归 > 回归 > 拟合回归模型 > 模型 可以向模型添加交互作用项和多项式项。默认情况下&#xff0c;模型仅包含在主对话框中输入的预测变量的主效应。添加项的方法有很多。假设预测变量列表具有 3 个连续变量 X、Y、Z 和 2 个类别…

WPF XAML(二)

一、前言 本文是 WPF XAML&#xff08;一&#xff09;的续文&#xff0c;链接我就放下面了。 WPF XAML&#xff08;一&#xff09;-CSDN博客https://blog.csdn.net/qq_71897293/article/details/135537094?spm1001.2014.3001.5501 二、XAML 中空白与特殊字符 在XAML中我们在…

鸿蒙ArkTS的起源和简介

theme: lilsnake 1、引言 Mozilla创造了JS&#xff0c;Microsoft创建了TS&#xff0c;Huawei进一步推出了ArkTS。 从最初的基础的逻辑交互能力&#xff0c;到具备类型系统的高效工程开发能力&#xff0c;再到融合声明式UI、多维状态管理等丰富的应用开发能力&#xff0c;共同…

TA百人计划学习笔记 2.6伽马矫正

资料 源视频 【技术美术百人计划】图形 2.6 伽马校正_哔哩哔哩_bilibili PPT 2600_伽马矫正 参考笔记 2.6伽马&#xff08;Gamma&#xff09;校正 语雀 从0开始的技术美术之路&#xff08;十&#xff09;伽马校正_线性工作流 技术美术-CSDN博客为什么 韦伯定理 人眼对于暗部是…

《MyBatis》-- 流式查询内存性能优化-单条数据加工

阿丹-需求/场景&#xff1a; 在项目场景中涉及到数据二次加工。需要将单个对象数据转为按照规定的数据字典的转换。以及需要转换数据结构。从对象转换为按照规定的值和规则的数组。 因为要写入csv文件&#xff0c;涉及到文件的输出流。 之前讨论针对的解决方案&#xff1a; …

HCIP第一次练习 -- RIP复习实验

要求&#xff1a; 需求:R1-R2-R3-R4-R5运行RIPV2 R6-R7运行RIPV1 1.使用合理地址规划网络&#xff0c;各自创建环回接口 2.R1创建环回172.16.1.1/24172.16.2.1/24 172.16.3.1/24 3.要求R3使用R2访问R1环回 4.减少路由条自数量,增加路由传递安全性 5.R5创建一个环回模拟运营商,不…

FFmpeg之SwrRessample

文章目录 一、概述二、重采样流程三、重要结构体3.1、SwrContext3.2、ResamplerContext 四、重要函数4.1、swr_alloc4.2、swr_alloc_set_opts4.3、av_opt_set_*4.4、swr_init4.5、av_samples_alloc_array_and_samples4.6、av_samples_alloc4.7、swr_convert4.8、swr_get_delay4…

Apache Solr <= 8.8.1任意文件读取漏洞复现CVE-2019-17558

一、环境准备 搭建环境vulhub&#xff0c;需要提前安装docker环境 docker安装&#xff1a;docker--安装docker-ce-CSDN博客 vulhub地址&#xff1a;https://github.com/vulhub/vulhub #创建靶场环境 mkdir /opt/vulhub cd /opt/vulhub git https://github.com/vulhub/vulhu…

Python基础知识:整理15 列表的sort方法

1 sorted() 方法 之前我们学习过 sorted() 方法&#xff0c;可以对列表、元组、集合及字典进行排序 # 1.列表 ls [1, 10, 8, 4, 5] ls_new sorted(ls, reverseTrue) print(ls_new) …

【Vue】后端返回文件流,前端预览文件

let date;request({url: this.$route.query.url,method: get,responseType: blob,}).then(resp > {date respthis.path window.URL.createObjectURL(new Blob([resp], {type: "application/pdf"}))}).catch((e) > {//旧版本浏览器下的blob创建对象window.Blo…