我有以下问题
我试着让文本在狗类型下换行,我试着让文本换行,很灵活,但它不工作不确定为什么它不能工作这里是我的代码
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
const Padding(
padding: EdgeInsets.only(right: 8.0, bottom: 4.0),
child: FaIcon(
FontAwesomeIcons.cubes,
size: 24,
color: primaryColor,
),
),
const Text(
'Dog Type: ',
style: AppStyles.dogProfileBodyLabelStyle,
overflow: TextOverflow.ellipsis,
),
Text(
dogInfo.dogType!.join(", "),
style: AppStyles.dogProfileBodyTextStyle,
maxLines: 5,
softWrap: true,
overflow: TextOverflow.ellipsis,
),
],
),
],
),
为了清楚起见,我希望它包装在Dog类型下,而不是像下面这样
发布于 2021-12-01 13:01:58
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Row(
children: [
const Padding(
padding: EdgeInsets.only(right: 8.0, bottom: 4.0),
child: FaIcon(
FontAwesomeIcons.cubes,
size: 24,
color: primaryColor,
),
),
const Text(
'Dog Type: ',
style: AppStyles.dogProfileBodyLabelStyle,
overflow: TextOverflow.ellipsis,
),
Expanded( //Wrap Text Widget with Expanded Widget
child: Text(
dogInfo.dogType!.join(", "),
style: AppStyles.dogProfileBodyTextStyle,
maxLines: 5,
softWrap: true,
overflow: TextOverflow.ellipsis,
),
),
],
),
],
),
或者使用RichText
小部件..
RichText(
text: TextSpan(
style: Theme.of(context).textTheme.bodyText1,
children: [
const TextSpan(text: 'Dog Type: '),
TextSpan(
text: dogInfo.dogType!.join(", "),
style:
const TextStyle(color: Color(0xFF003764)),
)
]),
),
https://stackoverflow.com/questions/70184607
复制相似问题