Я пытаюсь создать что-то подобное для моего приложения Flutter:
Сейчас я успешно получил строку с текстом, пунктирной линией и большим текстом за деньги. Моя последняя проблема, которую я, похоже, не могу решить, - это избавиться от разрыва в размерах текста разного размера.
[EDIT]
Я специально имею в виду, что все выровнено по одной красной линии:
Глядя на этот ответ Я подумал, что мог бы сделать то же самое и поместить весь текст в расположенные стопки. Это, однако, нарушает мой макет, давая мне эту ошибку:
I/flutter (26439): The following assertion was thrown during performLayout():
I/flutter (26439): RenderFlex children have non-zero flex but incoming height constraints are unbounded.
I/flutter (26439): When a column is in a parent that does not provide a finite height constraint, for example if it is
I/flutter (26439): in a vertical scrollable, it will try to shrink-wrap its children along the vertical axis. Setting a
I/flutter (26439): flex on a child (e.g. using Expanded) indicates that the child is to expand to fill the remaining
I/flutter (26439): space in the vertical direction.
I/flutter (26439): These two directives are mutually exclusive. If a parent is to shrink-wrap its child, the child
I/flutter (26439): cannot simultaneously expand to fit its parent.
I/flutter (26439): Consider setting mainAxisSize to MainAxisSize.min and using FlexFit.loose fits for the flexible
I/flutter (26439): children (using Flexible rather than Expanded). This will allow the flexible children to size
I/flutter (26439): themselves to less than the infinite remaining space they would otherwise be forced to take, and
I/flutter (26439): then will cause the RenderFlex to shrink-wrap the children rather than expanding to fit the maximum
I/flutter (26439): constraints provided by the parent.
I/flutter (26439): The affected RenderFlex is:
I/flutter (26439): RenderFlex#c7fb1 relayoutBoundary=up8 NEEDS-LAYOUT NEEDS-PAINT
I/flutter (26439): The creator information is set to:
I/flutter (26439): Column ← Expanded ← Row ← Column ← Padding ← RepaintBoundary-[<0>] ← IndexedSemantics ←
I/flutter (26439): NotificationListener<KeepAliveNotification> ← KeepAlive ← AutomaticKeepAlive ← SliverList ←
I/flutter (26439): MediaQuery ← ⋯
I/flutter (26439): See also: https://flutter.dev/layout/
Вот мой соответствующий код:
Row(
crossAxisAlignment: CrossAxisAlignment.end,
children: <Widget>[
Text('Salary Cap'),
// Stack( // Will cause error
// fit: StackFit.expand,
// children: <Widget>[
// Positioned(
// top: 0,
// left: 0,
// width: 200,
// child: Text('Salary Cap'),
// ),
// ],
// ),
Expanded(
child: Container(
width: double.infinity,
child: CustomPaint(painter: LineDashedPainter()),
),
),
RichText(
text: TextSpan(
children: <TextSpan>[
TextSpan(text: '\$'),
TextSpan(
text:
'${oCcy.format(salaryLimit)}',
style: Theme.of(context).textTheme.display1,
),
],
),
),
],
),
Любой совет?