简体   繁体   English

在 Flutter 中的 Row 小部件中呈现 CheckboxListTile 小部件时出错

[英]Error while rendering a CheckboxListTile widget in a Row widget in Flutter

So I have the following code:所以我有以下代码:

            Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween,
                children: [
                  CheckboxListTile(
                    title: Text("helo"),
                    controlAffinity: ListTileControlAffinity.leading,
                    value: true,
                    onChanged: null,

                  ),
                  Text(
                    "Forgot Password?",
                    style: TextStyle(color: Colors.blueGrey),
                  )
                ],
              ),

my aim is to create a "Remember me" check box and "Forgot Password?"我的目标是创建一个“记住我”复选框和“忘记密码?” in a row.连续。

When I run this code it gives me the following error:当我运行此代码时,出现以下错误:

RenderBox was not laid out: RenderMergeSemantics#19dcc relayoutBoundary=up8 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1785 pos 12: 'hasSize'
The relevant error-causing widget was Row lib\main.dart:106
═══════════════════════════════════════════════════════════════════════════════

════════ Exception caught by rendering library ═════════════════════════════════ 
RenderBox was not laid out:
_RenderColoredBox#cd072 relayoutBoundary=up14 
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1785 pos 12: 'hasSize'
The relevant error-causing widget was CheckboxListTile

Is there a way that I can get my desired output where the "Remember me" check box and "Forgot Password?"有没有一种方法可以让我在“记住我”复选框和“忘记密码”的地方获得我想要的 output? is in a Row?在一排?

Also, what is the problem with the current code?另外,当前代码有什么问题?

Wrap the CheckboxListTile in Expanded widget like shown below:CheckboxListTile包装在Expanded小部件中,如下所示:

Row(
    mainAxisAlignment: MainAxisAlignment.spaceBetween,
    children: [
      Expanded(
        child: CheckboxListTile(
          title: Text("helo"),
          controlAffinity: ListTileControlAffinity.leading,
          value: true,
          onChanged: null,

        ),
      ),
      Text(
        "Forgot Password?",
        style: TextStyle(color: Colors.blueGrey),
      )
    ],
  ),

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM