【问题标题】:owner._debugCurrentBuildTarget == this , is not trueowner._debugCurrentBuildTarget == this ,不正确
【发布时间】:2020-03-26 14:16:42
【问题描述】:

[on web] 尝试将一些小部件放入 FittedBox 中,如下所示:

 FittedBox(
   fit: BoxFit.scaleDown,
   child: AnimatedContainer(...)
 )

但屏幕和控制台仅显示此消息:

控制台中没有其他内容

下一步是什么? :D

【问题讨论】:

    标签: flutter flutter-layout flutter-web


    【解决方案1】:

    我在 CustomScrollView 内遇到此错误,因为我的一个小部件不在 SliverToBoxAdapter 内。

    SliverToBoxAdapter(
      child: Row(
        children: [
          Text('Activity',
          style: TextStyle(fontWeight: FontWeight.w600, fontSize: 18),),
        ],
      ),
    )
    

    我只是确保您的条子列表中的所有小部件实际上都是条子。

    【讨论】:

    • 这个答案是正确的。它解决了我的问题。
    【解决方案2】:

    更多信息是在对代码进行了一些修改后由框架提供的,例如额外的孩子,父母的随机尺寸。 . .

    错误 >> ... object was given an infinite size during layout

    最终一些这样的工作:

    FittedBox(
     fit: BoxFit.scaleDown,
     child: Container(
       height: MediaQuery.of(context).size.height * .65,
       child: AnimatedContainer(...)
    )
    

    【讨论】:

      【解决方案3】:

      我收到此错误是因为在我的代码的某个地方,我错误地应用了错误的小部件,而这与我正在编写的无状态小部件相同。为了更清楚:

      stateless widget - MyWidget //For example
      .
      .
      .
      Now somewhere in between the code:
      
      Column(
      children: [
      MyWidget(), //This went wrong, I was supposed to Use some other widget.
      ]);
      

      【讨论】:

        猜你喜欢
        • 2021-01-29
        • 2021-10-28
        • 2021-09-26
        • 2021-02-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2021-05-03
        • 1970-01-01
        相关资源
        最近更新 更多