flutter - 在 Flutter 中添加新文本行的问题
问题描述
appBar: PreferredSize(
preferredSize: Size.fromHeight(330.0),
child: AppBar (
backgroundColor: Color(0xFF1D153B),
title: RichText(
text: TextSpan (
style: DefaultTextStyle.of(context).style,
children: <TextSpan> [
TextSpan (text :'Makan Bang'),
TextSpan (text :'Makan Bang'),
TextSpan (text :'Makan Bang'),
],
),
),
),
终端说“没有名为'children'的命名参数”。除了使用 RichText 小部件之外,我还有其他方法可以添加新的文本行吗?
解决方案
在剪切标题小部件的边界之前,您最多可以有两/三行:
child: AppBar(
backgroundColor: Color(0xFF1D153B),
title: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text('first line'),
Text('second line'),
],
),
),
或者您可以使用 AppBar 的灵活空间属性(背景空间)来添加小部件:
child: AppBar(
backgroundColor: Color(0xFF1D153B),
flexibleSpace: Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: <Widget>[
Text('example text'),
Text('example text'),
Text('example text'),
Text('example text'),
Text('example text'),
Text('example text'),
Text('example text'),
Text('example text'),
],
),
),
推荐阅读
- python - Python 用平均值估算缺失值,帮我试试这段代码,但出错了
- django - 如何在 Django REST Framework 序列化程序中获取相关字段的相关字段?
- javascript - 使用 React 编写组件的各种方式之间有什么区别
- docker - 为什么我不能在我的 docker 容器中执行命令 pwd 或任何命令?
- javascript - 逐步测试不断变化的数据的最佳方法
- c# - 在我的 dot net core 2.2 项目中使用 ConfuserEx
- python - 何时使用 Apache Beam Pipeline 对象?
- python - 根据两列的条件创建数据框
- solidity - “未提供 SPDX 许可证标识符”警告 - 这是什么意思?
- python - ssl.SSLError: ("糟糕的握手: SysCallError(54, 'ECONNRESET')",)