在 flutter 打中,我在使用crossAxisAlignment: CrossAxisAlignment.baseline
时出错
错误::
Failed assertion: line 3791 pos 15: 'crossAxisAlignment != CrossAxisAlignment.baseline || textBaseline != null': is not true.
码::
Row(
crossAxisAlignment: CrossAxisAlignment.baseline,
children: <Widget>[
Text(
'192',
style: kBoldNumberText,
),
Text(
'cm',
style: kLabelText,
)
],
)
最佳答案
在 flutter 中使用crossAxisAlignment
时,我们需要告诉要对齐的元素,为此,我们可以按字母顺序或图形形式使用textBaseline: TextBaseline.alphabetic
//alphabetic:::
textBaseline: TextBaseline.alphabetic,
-要么-
//graphic:::
textBaseline: TextBaseline.ideographic
就我而言,它是
alphabetic:::
,所以我重写了Row(
crossAxisAlignment: CrossAxisAlignment.baseline,
textBaseline: TextBaseline.alphabetic, ////<-- HERE --> ////
children: <Widget>[
Text(
'192',
style: kBoldNumberText,
),
Text(
'cm',
style: kLabelText,
)
],
)