android开发Flutter Text自动换行实现
flutter 自动换行处理
flutter自动换行有几种场景:column中,row中
在Column中的Text不用任何处理,能够自动换行。
在Row中的Text需要用Expanded包裹。因为文字是水平方向排放的,和Row的计算规则冲突,需要使用Expanded包裹,表示剩下的给Text,Text自然知道自身宽度,才能实现自动换行。
Row(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
const SizedBox(width: 6),
Expanded(
child: Text(voiceText,style: const TextStyle(color: Color(0xFF0A0B07), fontSize: 16),),
),
const SizedBox(width: 40, height: 80)
],
)