我正在遵循 this 的示例教程。
如果我想将两个文本组件添加到子数组中,我会收到标题警告。
例如:
Widget titleSection = Container(
child: Row(
//need to expand the rows on the column
children: [
Expanded(
child: Column(
children: [
const Text(
'Hello1',
),
const Text(
'Hello2',
),
],
)
],
),
);
我做错了什么?
最佳答案
在你的情况下应该是
Widget titleSection = Container(
child: Row(
//need to expand the rows on the column
children: [
Expanded(
child: Column(
children: const [
Text(
'Hello1',
),
Text(
'Hello2',
),
],
),
)
],
),
);
关于flutter - 更喜欢 const 文字作为 @immutable 类上构造函数的参数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69002584/