我有以下代码:
Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
CheckboxListTile(
title: Text("helo"),
controlAffinity: ListTileControlAffinity.leading,
value: true,
onChanged: null,
),
Text(
"Forgot Password?",
style: TextStyle(color: Colors.blueGrey),
)
],
),
我的目标是在同一排中创建一个“记住我”复选框和“忘记密码”链接。
当我运行这段代码时,它会给出以下错误:
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
有没有办法让“记住我”复选框和“忘记密码?”在同一行中显示?此外,当前代码有什么问题?
CheckboxListTile
包裹在Expanded
中。 - Ketan Ramteke