英文:
Flutter animated Row overflow inside box smaller than a child
问题
以下是翻译好的部分:
Overflow error (溢出错误)
How can this be avoided? (如何避免这个问题?)
This is code (这是代码):
英文:
There is a box in which I need to animate a child consisting of a Row in which there are two Text. (In short - running line). Both texts in the result must be on the same line.
The child I want to animate is wider than the parent anyway and when animating, an overflow error pops up.
Overflow error
How can this be avoided?
This is code:
final Widget content = SizedBox(
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text('TEXT 1'),
Text('TEXT 2')
],
),
);
@override
Widget build(BuildContext context) {
return
Container(
alignment: Alignment.center,
width: widget.parentWidth,
height: UI_SIZE,
child: ClipPath(
clipBehavior: Clip.hardEdge,
child: SlideTransition(
position: _offsetAnimation,
child: content,
),
),
);
}
答案1
得分: 0
I was able to fix it with OverflowBox
.
final Widget content = OverflowBox(
maxWidth: double.infinity,
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text('TEXT 1'),
Text('TEXT 2')
],
),
);
Maybe someone will help this solution.
英文:
I was able to fix it with OverflowBox
.
final Widget content = OverflowBox(
maxWidth: double.infinity,
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Text('TEXT 1'),
Text('TEXT 2')
],
),
);
Maybe someone will help this solution
答案2
得分: 0
以下是您要翻译的内容:
尝试这个
final Widget content = SizedBox(
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Expanded(child: Text('文本 1'),),
Expanded(child: Text('文本 2'),),
],
),
);
英文:
try this
final Widget content = SizedBox(
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: [
Expanded(child: Text('TEXT 1'),),
Expanded(child: Text('TEXT 2'),),
],
),
);
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论