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

出现这个问题的原因可能是因为你把一个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.mzph.cn/news/627324.shtml

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

相关文章

嵌入式工作岗位未来会不会越来越少?

今日话题&#xff0c;嵌入式工作岗位未来会不会越来越少&#xff1f;未来的嵌入式岗位机会将会逐渐增多&#xff0c;因为嵌入式技术是万物互联的基础&#xff0c;从智能手表到智能汽车&#xff0c;嵌入式都扮演着关键角色。虽然相比计算机科学CS&#xff0c;嵌入式领域的天花板…

中间件框架知识进阶

概述 近期从不同渠道了解到了一些中间件相关的新的知识&#xff0c;记录一下收获。涉及到的中间件包括RPC调用、动态配置中心、MQ、缓存、数据库、限流等&#xff0c;通过对比加深理解&#xff0c;方便实际应用时候更明确如何进行设计和技术选型。 一、RPC框架中间件系列 1、…

华清远见作业第二十七天——网络编程(第二天)

思维导图&#xff1a; 在虚拟机实现客户端控制机械臂 代码&#xff1a; #include<stdio.h> #include<string.h> #include<stdlib.h> #include <sys/types.h> #include <sys/stat.h> #include <a.h> #define SER_PORT 8888 //服务端口 #d…

SpringBoot 启动优化实践!

背景 公司 SpringBoot 项目在日常开发过程中发现服务启动过程异常缓慢&#xff0c;常常需要 6-7 分钟才能暴露端口&#xff0c;严重降低开发效率。通过 SpringBoot 的 SpringApplicationRunListener 、BeanPostProcessor 原理和源码调试等手段排查发现&#xff0c;在 Bean 扫描…

Linux安装Rdkafka PHP 扩展(Kafka使用教程)

以是centos为例 #可以查看php版本 php -v#查看php安装的扩展库 php -m 1、首先&#xff0c;确保你已经安装了 PHP 和相关的开发工具。你可以使用以下命令来安装它们&#xff1a; sudo yum install php-devel 中间会问你是否ok&#xff0c;输入y回车&#xff0c;出现complete…

pycharm debug显示的变量过多

问题&#xff1a; https://blog.csdn.net/Hodors/article/details/117535731 解决方法&#xff1a; 把"Show console variables by default"前面的勾取消掉就行 参考&#xff1a; https://stackoverflow.com/questions/48969556/hide-console-variables-in-pychar…

数据结构——二叉树(先序、中序、后序及层次四种遍历(C语言版))超详细~ (✧∇✧) Q_Q

目录 二叉树的定义&#xff1a; *特殊的二叉树&#xff1a; 二叉树的性质&#xff1a; 二叉树的声明&#xff1a; 二叉树的先序遍历&#xff1a; 二叉树的中序遍历&#xff1a; 二叉树的后序遍历&#xff1a; 二叉树的层序遍历&#xff1a; 二叉树的节点个数&#xff1a; 二叉…

使用netdxf(C#)框架实现dxf文件读取与导出坐标

使用netdxf&#xff08;C#&#xff09;框架实现dxf文件读取与导出坐标 一、新建窗体应用程序DxfToolDemo&#xff0c;将默认的Form1重命名为FormDxfTool 窗体FormDxfTool.Designer.cs设计器源程序如下&#xff1a; namespace DxfToolDemo {partial class FormDxfTool{/// <…

x-cmd pkg | magic-wormhole - (魔法虫洞)文件传输工具

目录 简介首次用户功能特点竞品和相关作品进一步探索 简介 magic-wormhole 是一个用于在两台计算机之间安全传输文件的工具。它通过创建一个临时的点对点连接&#xff0c;允许用户将文件或文本从一台计算机发送到另一台计算机。 它使用 PAKE 这一系列的加密算法&#xff0c;通…

扫地机行业研究:预计2028年将达到78.51亿美元

吸尘器、扫地机器人、洗地机为清洁电器中最亮眼的三大品类。吸尘器主要用来吸尘&#xff0c;扫地机的主要作用也是用于除尘&#xff0c;具备扫拖一体功能的扫地机&#xff0c;干湿混合垃圾暂时做不到干净清理。洗地机集齐了“吸、拖、洗”三种功能为一体&#xff0c;并且具备自…

消息队列-RockMQ-定时延时发送消息

定时延时发送消息 任务需要延迟一段时间再进行处理。 生产者 public class Producer {public static void main(String[] args) throws Exception {DefaultMQProducer producer new DefaultMQProducer("producer_group");producer.setNamesrvAddr("ip:9876&q…

【Python 数据分析】数据预处理:z-score 标准化、min-max 归一化、数据缺失值处理、数据重复处理

目录 简述 / 前言1. z-score 标准化2. min-max 归一化3. 数据缺失值处理4. 数据重复处理 简述 / 前言 本篇文章分享数据分析中最重要的一个步骤&#xff1a;数据预处理。我们在做数据分析之前&#xff0c;都需要采集很多数据&#xff0c;这些数据可能是从官网下载的&#xff0…

【docker-compose】【nginx】内网环境https配置

目录 1、openssl生成自签名证书和私钥2、nginx.conf配置ssl3、docker-compose挂载 1、openssl生成自签名证书和私钥 在部署服务器上&#xff0c;新建cert目录&#xff0c;执行以下指令&#xff0c;然后生成.crt和.key文件 openssl req -newkey rsa:2048 -nodes -keyout rsa_pri…

linux yum仓库

yum是基于rpm包构建的软件更新机制&#xff0c;能够自动解决软件包之间的依赖关系。 常用命令 查询 yum list [软件名] 显示可用的安装包&#xff0c;如果不加软件名则显示所有的可用包 yum info [软件名] 显示安装包的详细信息 如果不加软件名是显示所有包…

2024年【上海市安全员B证】考试试卷及上海市安全员B证复审模拟考试

题库来源&#xff1a;安全生产模拟考试一点通公众号小程序 上海市安全员B证考试试卷根据新上海市安全员B证考试大纲要求&#xff0c;安全生产模拟考试一点通将上海市安全员B证模拟考试试题进行汇编&#xff0c;组成一套上海市安全员B证全真模拟考试试题&#xff0c;学员可通过…

海外短剧APP小程序开发 随心随意畅享大片

随着智能手机的普及和网络的高速发展&#xff0c;短剧APP已经成为当今热门的观影方式。作为一种全新的观影体验&#xff0c;海外短剧APP以其丰富多样的内容吸引了大量用户。本文将为您介绍海外短剧APP开发的相关知识和其所带来的优势&#xff0c;以及市场前景和发展趋势。 海外…

jsonschema,一个超强的 Python 库!

更多资料获取 &#x1f4da; 个人网站&#xff1a;ipengtao.com 大家好&#xff0c;今天为大家分享一个超强的 Python 库 - jsonschema。 Github地址&#xff1a;https://github.com/python-jsonschema/jsonschema JSON&#xff08;JavaScript Object Notation&#xff09;是…

MySQL 多版本并发控制 MVCC

MVCC出现背景 事务的4个隔离级别以及对应的三种异常 读未提交&#xff08;Read uncommitted&#xff09; 读已提交&#xff08;Read committed&#xff09;&#xff1a;脏读 可重复读&#xff08;Repeatable read&#xff09;&#xff1a;不可重复读 串行化&#xff08;Se…

.NET领域最硬核的gRPC 核心能力一把梭

前言&#xff0c;本文定位为.NET方向 grpc核心能力一把梭&#xff0c;全篇是姿势性和结论性的展示&#xff0c; 方便中高级程序员快速上手.NET Grpc。 有关grpc更深层次的前世今生、底层原理、困惑点释疑请听下回分解&#xff0c; 欢迎菜鸟老鸟们提出宝贵意见。 grpc宏观目标&…

跨平台进程/任务管理服务——Meproc的配置

配置 Meproc的配置非常简单&#xff0c;只有以下几个配置选项。 Conf [ip: 0.0.0.0,port: 8606,log_level: debug,log_dir: /tmp,web: [ip: 127.0.0.1,port: 8606,],bootstrap_cmd: , ];ip 是 Meproc 服务监听 HTTP 请求的地址。port 是Meproc服务监听HTTP请求的端口。log_l…