ListView 内的颤动行

2024-05-25

我正在尝试添加一个Row在列表视图内并收到错误

I/flutter (13858): ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter (13858): The following assertion was thrown during performLayout():
I/flutter (13858): BoxConstraints forces an infinite height.
I/flutter (13858): These invalid constraints were provided to RenderParagraph's layout() function by the following
I/flutter (13858): function, which probably computed the invalid constraints in question:
I/flutter (13858):   RenderFlex.performLayout (package:flutter/src/rendering/flex.dart:805:17)
I/flutter (13858): The offending constraints were:
I/flutter (13858):   BoxConstraints(w=72.0, h=Infinity)

按照发现该错误的指导,我尝试包装我的ListView in an Expanded,但这只会导致Expanded widgets must be placed inside Flex widgets.,这导致我尝试另一种方法......并最终返回同样的错误。

我的小部件如下。有办法让它发挥作用吗?我最终想要做的是显示多组行,行之间有一些文本,允许用户上下滚动页面。

class _RoutineEditState extends State<RoutineEdit> {
  String routineName;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Edit Routine'),
      ),
      body: ListView(
        //padding: EdgeInsets.fromLTRB(10, 15, 10, 5),
        children: <Widget>[
          Text('ddedede'),
          Row(
            crossAxisAlignment: CrossAxisAlignment.stretch,
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Text('Set'),
            ],
          ),
        ],
      ),
    );
  }
}

因为我不知道你想要的布局。

只是为了修复错误。我们有三个选择。

First: use - IntrinsicHeight widget.

code:

@override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Edit Routine'),
      ),
      body: ListView(
        //shrinkWrap: true,
        //padding: EdgeInsets.fromLTRB(10, 15, 10, 5),
        children: <Widget>[
          Text('ddedede'),
          IntrinsicHeight(
            child: Row(
              crossAxisAlignment: CrossAxisAlignment.stretch,
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Text('Set'),
                Text('Set'),
                Text('Set'),
              ],
            ),
          ),
        ],
      ),
    );
  }

Second:将你的行包裹起来LimitedBox并保持-crossAxisAlignment: CrossAxisAlignment.stretch

code:

@override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Edit Routine'),
      ),
      body: ListView(
        shrinkWrap: true,
        //padding: EdgeInsets.fromLTRB(10, 15, 10, 5),
        children: <Widget>[
          Text('ddedede'),
          LimitedBox(
            maxHeight: 200.0,
            child: Row(
              crossAxisAlignment: CrossAxisAlignment.stretch,
              mainAxisAlignment: MainAxisAlignment.center,
              children: [
                Text('Set'),
                Text('Set'),
                Text('Set'),
              ],
            ),
          ),
        ],
      ),
    );
  }

Third:删除或评论 -crossAxisAlignment: CrossAxisAlignment.stretch

@override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('Edit Routine'),
      ),
      body: ListView(
        shrinkWrap: true,
        //padding: EdgeInsets.fromLTRB(10, 15, 10, 5),
        children: <Widget>[
          Text('ddedede'),
          Row(
           // crossAxisAlignment: CrossAxisAlignment.stretch,
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              Text('Set'),
              Text('Set'),
              Text('Set'),
            ],
          ),
        ],
      ),
    );
  }
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)

ListView 内的颤动行 的相关文章

随机推荐

  • Python->Beautifulsoup->Webscraping->循环 URL(1 到 53)并保存结果

    这是我正在尝试抓取的网站 http livingwage mit edu http livingwage mit edu 具体网址来自 http livingwage mit edu states 01 http livingwage mi
  • C 函数声明中的无类型参数

    最近我一直在查看 Steven Skiena 的在线资源中的一些 C 示例代码 算法设计手册 http www cs sunysb edu skiena algorist book programs 并且对他的一些函数调用的语法感到困惑 诚
  • 如何使用ssh直接连接远程docker容器

    我想直接使用 ssh 连接到远程运行的 Docker 容器 通常我可以 ssh i privateKey user host docker ps which will list all running containers docker e
  • 如何保持诗歌和承诺版本同步?

    我有一个pyproject toml with tool poetry name my project version 0 1 0 tool commitizen name cz conventional commits version 0
  • ZF2 共享模块事件管理器

    当特定情况发生时 我需要在每个模块中实现一个事件触发器 我还需要所有其他模块在触发该事件时必须执行某些工作 请注意这一点 我正在尝试创建一些通用端点 我可以在其中发送触发器 并且所有模块都需要监听 但我在弄清楚如何实现这一点时遇到了一些麻烦
  • 将 Bootstrap 导航栏列表项包裹在居中的品牌图像周围

    我整晚都在搞乱这个问题 没有解决办法 我正在使用 bootstrap 2 32 对于 joomla 模板 尚不支持 BS3 并且我将拥有动态数量的列表项 我需要将列表项居中 但也同样包裹在中心 brand img 的左侧和右侧 我可以把它分
  • 包含 Qt 标头的正确方法是什么?

    到目前为止我知道几种方法 includeQt 类 include
  • java中的EhCache默认缓存

    我对 ehCache 有这样的配置
  • Azure DevOps - 使用 GUI 而不是 YAML 来编辑构建管道

    不久前 Azure DevOps 添加了对 YAML 构建管道的支持 这对于高级用户来说非常好 我明白 专业人士只使用命令行和纯文本工具 GUI 适合弱用户 原因有很多 有没有办法返回 GUI 经典编辑器 来编辑现有管道 我已禁用该功能 如
  • 更短的 POST 验证方式?

    我总是进行 POST 的检查验证 有时它会变得太混乱和冗长 保持简短和整洁的最佳方法是什么 Example if isset POST albumName trim POST albumName isset POST slugName PO
  • 在 Spring Batch 的 SkipPolicy 中访问作业文件名参数

    我有一份 Spring Batch 的工作 我使用 BeanIO 读取一些文件 并且我会处理无效文件 所以我创建了一个 SkipPolicy 类 public class FileVerificationSkipper implements
  • Perl 脚本的 shebang 行应该使用什么?

    哪一个用作 Perl 脚本的 shebang 行更好或更快 perl perl exe fullpath perl perl exe partialpath perl perl exe 并且 当使用 perl 当它在特定系统上运行时 我如何
  • 从另一个线程在主线程中运行代码

    在 android 服务中 我创建了线程来执行一些后台任务 我遇到一种情况 线程需要在主线程消息队列上发布某些任务 例如Runnable 有没有办法得到Handler主线程和帖子的Message Runnable从我的另一个线程到它 注意
  • 在 Chrome 中显示输入 type=date-local 的秒数

    在谷歌浏览器中 如果我设置 type 输入的值datetime local包含秒的时间 其中秒值为 0 Chrome 决定不在输入中显示秒值 这意味着用户根本无法设置秒 例如 如果我将值设置为2013 10 24T20 36 01然后Chr
  • 甜甜圈孔缓存 - 排除 MiniProfiler.RenderInincludes

    我有一个 ASP NET MVC 操作 它装饰有OutputCache属性 但问题是 MiniProfiler 输出也被缓存 我想从缓存中排除 MiniProfiler 输出 甜甜圈洞 但我不确定如何排除像 MiniProfiler Ren
  • 填充错误 - 在 Java 中使用 AES 加密并在 C 中使用解密时

    我在用 rijndael c 代码解密 xl 文件时遇到问题 该文件通过 JCE 在 Java 中加密 并且此问题仅发生在具有公式的 excel 文件类型中 其余所有文件类型加密 解密均正常进行 如果我在 java 中解密同一个文件 输出就
  • 解密电子邮件中附加的 gpg 文件 (file.pgp)

    我使用 email Message 类和 gnupg 库来 1 解析从 Twisted imap4 客户端获取的电子邮件字符串 2 获取附件 pgp 3 解密 我可以解密典型的邮件内容 如下所示 BEGIN PGP MESSAGE Vers
  • 设置`ylabel`的位置

    我正在尝试使用 matplotlib 重新创建下图的外观 但是 我对放置位置有疑问ylabel 我想要它在顶部y 轴 如图所示 我尝试过设置它的位置ax yaxis set label position 但这只接受left or right
  • SQL Server xp_delete_file 参数

    谁能解释一下清单xp Delete filesql server 中的参数 我没有找到此存储过程的 msdn 文档 我从维护计划中获取了 xp Delete file 脚本 但不理解第一个参数 xp delete file取五个参数 文件类
  • ListView 内的颤动行

    我正在尝试添加一个Row在列表视图内并收到错误 I flutter 13858 EXCEPTION CAUGHT BY RENDERING LIBRARY I flutter 13858 The following assertion wa