Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/user-interface/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
User interface 按系数调整动态大小的小部件的大小_User Interface_Layout_Dart_Flutter - Fatal编程技术网

User interface 按系数调整动态大小的小部件的大小

User interface 按系数调整动态大小的小部件的大小,user-interface,layout,dart,flutter,User Interface,Layout,Dart,Flutter,我正在尝试设置动态大小的小部件的高度因子(用于动画),在本例中为文本: Stack( children: <Widget>[ Column( crossAxisAlignment: CrossAxisAlignment.stretch, children: <Widget>[ FractionallySizedBox( heightFactor: 0.5, child: Text(

我正在尝试设置动态大小的
小部件的
高度因子
(用于动画),在本例中为
文本

Stack(
  children: <Widget>[
    Column(
      crossAxisAlignment: CrossAxisAlignment.stretch,
      children: <Widget>[
        FractionallySizedBox(
          heightFactor: 0.5,
          child: Text(
            "Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.",
          ),
        ),
      ],
    ),
    Positioned.fill(
      child: Center(
        child: Text(
          "Lorem ipsum".toUpperCase(),
        ),
      ),
    ),
  ],
);
文本
包装在
限制框
约束框
中似乎只会更改错误消息中提供的无效约束

MainAxisSize.min
添加到
Column.MainAxisSize
似乎也没有什么不同


有没有一种方法可以避免这个错误呢?

一个部分物理化的数据库将自己的大小调整到它的父级。因为在堆栈中使用列,所以它实际上没有无限高的限制。因为
infinity/2==infinity
你的文本因此也有无限高


如果切换到使用对齐,则可以根据文本而不是父对象调整对象的大小。

您需要提供更多的代码,而不仅仅是这样-现在我只能说,无论您的分数物理化盒子调整自身大小,都必须具有无限高度。由于
infinity/2==infinity
您的文本也具有无限高。使用Align小部件可能会更幸运,但在不知道小部件的情况下很难判断。好的,更新了更多代码,很抱歉给您带来不便。如果您能描述一下您正试图通过这样做实现的目标,这也会很有帮助。好的,
Align
似乎可以做到这一点,因此,我将重新措辞这个问题并添加一个答案。谢谢你的建议。好吧,我可以补充一下作为答案,哈哈。很高兴这有帮助。
I/flutter ( 7123): ══╡ EXCEPTION CAUGHT BY RENDERING LIBRARY ╞═════════════════════════════════════════════════════════
I/flutter ( 7123): The following assertion was thrown during performLayout():
I/flutter ( 7123): BoxConstraints forces an infinite height.
I/flutter ( 7123): These invalid constraints were provided to RenderParagraph's layout() function by the following
I/flutter ( 7123): function, which probably computed the invalid constraints in question:
I/flutter ( 7123):   RenderFractionallySizedOverflowBox.performLayout
I/flutter ( 7123):   (package:flutter/src/rendering/shifted_box.dart:909:13)
I/flutter ( 7123): The offending constraints were:
I/flutter ( 7123):   BoxConstraints(w=272.0, h=Infinity)