flutter - Flutter:带有 TextFormField 标题和副标题的 ListTile
问题描述
当我尝试使用包含 TextFormField 的标题创建 ListTile 时,我无法添加副标题,否则它会爆炸。
这是一个简单的例子:
ListTile(
title: TextFormField(
initialValue: 'foo',
),
subtitle: const Text('bar'),
),
当我将此片段添加到我的代码并运行它时,我得到:
I/flutter (20366): RenderParagraph#3f385 relayoutBoundary=up8 NEEDS-PAINT
I/flutter (20366): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter (20366): Another exception was thrown: RenderBox was not laid out: _RenderListTile#76527 relayoutBoundary=up7 NEEDS-PAINT
I/flutter (20366): Another exception was thrown: RenderBox was not laid out: RenderPadding#61d3e relayoutBoundary=up6 NEEDS-PAINT
I/flutter (20366): Another exception was thrown: RenderBox was not laid out: RenderSemanticsAnnotations#eaf9a relayoutBoundary=up5 NEEDS-PAINT
I/flutter (20366): Another exception was thrown: RenderBox was not laid out: RenderPointerListener#479d1 relayoutBoundary=up4 NEEDS-PAINT
I/flutter (20366): Another exception was thrown: RenderBox was not laid out: RenderSemanticsGestureHandler#1419c relayoutBoundary=up3 NEEDS-PAINT
I/flutter (20366): Another exception was thrown: 'package:flutter/src/rendering/shifted_box.dart': Failed assertion: line 310 pos 12: 'child.hasSize': is not true.
I/flutter (20366): Another exception was thrown: NoSuchMethodError: The method '<=' was called on null.
D/ (20366): HostConnection::get() New Host Connection established 0xd0a0ab40, tid 20389
W/ (20366): Unrecognized GLES max version string in extensions:
这是一个错误还是这只是一个无效的请求?
我的最终目标是创建一个显示标签和单位的 TextFormField。例如,用户可以在其中键入以英尺为单位的测量距离值的字段。
解决方案
推荐阅读
- javascript - axios中如何处理异步任务
- java - 为什么匿名类不能访问私有方法和变量?
- excel - 当 VBA 代码到达第 1,048,576 行时如何更改目标输出
- compiler-errors - 无法找到图像(在 Ren'py 视觉小说引擎中使用 Atom 进行视觉小说创作的编码)
- reactjs - 如何在 Electron+React 中添加菜单?
- java - 沿 Path.quadTo 贝塞尔曲线查找 Y 坐标
- python - 在Python中将分类列拆分为多个列?
- java - 在 ObjectArrayList JAVA 中编辑对象的值
- vue.js - Sequelize,不能运行 2 创建彼此
- css - CSS 特性以及如何查找类