如何连续使用堆栈:'package:flutter/src/rendering/object.dart': Failed assertion: line 1704 pos 12: '!_debugDoingThisLayout': is not true

时间:2021-01-17 08:25:32

标签: flutter flutter-layout

这是我的小部件树,

Column(
      children: [
        Expanded(
          child: StreamBuilder( ),
        ),
        Container(
          padding: const EdgeInsets.symmetric(horizontal: 10.0, vertical: 10.0),
          color: Theme.of(context).primaryColor,
          width: double.infinity,
          child: Row(
            children: [
              InkWell( ),
              SizedBox(
                width: 5.0,
              ),
              Expanded(
                child :Stack(
                  children: [
                  TextField(),
                  Container(),
                ],
              ),
            ),
            StreamBuilder(),
            InkWell(),
            ],
          ),
        )
      ],
    );

这是我得到的错误

======== Exception caught by rendering library =====================================================
The following assertion was thrown during performLayout():
'package:flutter/src/rendering/object.dart': Failed assertion: line 1704 pos 12: '!_debugDoingThisLayout': is not true.


Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=BUG.md

The relevant error-causing widget was: 
  Column file:///D:/MY_PROJECTS/flutter_projects/my_app/lib/screens/chat_screen.dart:190:12
When the exception was thrown, this was the stack: 
#2      RenderObject.layout (package:flutter/src/rendering/object.dart:1704:12)
#3      RenderFlex.performLayout (package:flutter/src/rendering/flex.dart:768:15)
#4      RenderObject.layout (package:flutter/src/rendering/object.dart:1777:7)
#5      MultiChildLayoutDelegate.layoutChild (package:flutter/src/rendering/custom_layout.dart:171:12)
#6      _ScaffoldLayout.performLayout (package:flutter/src/material/scaffold.dart:498:7)
...
The following RenderObject was being processed when the exception was fired: RenderFlex#ca889 relayoutBoundary=up4 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...  needs compositing
...  parentData: offset=Offset(0.0, 0.0); id=_ScaffoldSlot.body (can use size)
...  constraints: BoxConstraints(0.0<=w<=423.5, 0.0<=h<=720.1)
...  size: MISSING
...  direction: vertical
...  mainAxisAlignment: start
...  mainAxisSize: max
...  crossAxisAlignment: center
...  verticalDirection: down
RenderObject: RenderFlex#ca889 relayoutBoundary=up4 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
  needs compositing
  parentData: offset=Offset(0.0, 0.0); id=_ScaffoldSlot.body (can use size)
  constraints: BoxConstraints(0.0<=w<=423.5, 0.0<=h<=720.1)
  size: MISSING
  direction: vertical
  mainAxisAlignment: start
  mainAxisSize: max
  crossAxisAlignment: center
  verticalDirection: down
...  child 1: RenderPositionedBox#263fc NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...    parentData: offset=Offset(0.0, 0.0); flex=1; fit=FlexFit.tight
...    constraints: MISSING
...    size: MISSING
...    alignment: center
...    textDirection: ltr
...    widthFactor: expand
...    heightFactor: expand
...    child: RenderSemanticsAnnotations#87544 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...      parentData: offset=Offset(0.0, 0.0)
...      constraints: MISSING
...      size: MISSING
...      child: RenderConstrainedBox#26d04 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...        parentData: <none>
...        constraints: MISSING
...        size: MISSING
...        additionalConstraints: BoxConstraints(36.0<=w<=Infinity, 36.0<=h<=Infinity)
...        child: RenderCustomPaint#3ac7e NEEDS-LAYOUT NEEDS-PAINT
...          parentData: <none>
...          constraints: MISSING
...          size: MISSING
...  child 2: RenderConstrainedBox#97ac3 relayoutBoundary=up5 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...    needs compositing
...    parentData: offset=Offset(0.0, 0.0); flex=null; fit=null (can use size)
...    constraints: BoxConstraints(0.0<=w<=423.5, 0.0<=h<=Infinity)
...    size: MISSING
...    additionalConstraints: BoxConstraints(w=Infinity, 0.0<=h<=Infinity)
...    child: _RenderColoredBox#50f62 relayoutBoundary=up6 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...      needs compositing
...      parentData: <none> (can use size)
...      constraints: BoxConstraints(w=423.5, 0.0<=h<=Infinity)
...      size: MISSING
...      behavior: opaque
...      child: RenderPadding#f4661 relayoutBoundary=up7 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...        needs compositing
...        parentData: <none> (can use size)
...        constraints: BoxConstraints(w=423.5, 0.0<=h<=Infinity)
...        size: MISSING
...        padding: EdgeInsets.all(10.0)
...        textDirection: ltr
...        child: RenderFlex#0a1f3 relayoutBoundary=up8 NEEDS-LAYOUT NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
...          needs compositing
...          parentData: offset=Offset(10.0, 10.0) (can use size)
...          constraints: BoxConstraints(w=403.5, 0.0<=h<=Infinity)
...          size: MISSING
...          direction: horizontal
...          mainAxisAlignment: start
...          mainAxisSize: max
...          crossAxisAlignment: center
...          textDirection: ltr
...          verticalDirection: down
...          textBaseline: alphabetic
====================================================================================================

======== Exception caught by rendering library =====================================================
RenderBox was not laid out: RenderFlex#ca889 relayoutBoundary=up4 NEEDS-PAINT NEEDS-COMPOSITING-BITS-UPDATE
'package:flutter/src/rendering/box.dart':
Failed assertion: line 1785 pos 12: 'hasSize'
The relevant error-causing widget was: 
  Scaffold file:///D:/MY_PROJECTS/flutter_projects/sabr_health_app/lib/screens/chat_screen.dart:126:11
====================================================================================================
Reloaded 13 of 1351 libraries in 1,855ms.

======== Exception caught by rendering library =====================================================
The following _CastError was thrown during paint():
Null check operator used on a null value

The relevant error-causing widget was: 
  Column file:///D:/MY_PROJECTS/flutter_projects/sabr_health_app/lib/screens/chat_screen.dart:190:12
When the exception was thrown, this was the stack: 
#0      RenderFlex._hasOverflow (package:flutter/src/rendering/flex.dart:487:37)
#1      RenderFlex.paint (package:flutter/src/rendering/flex.dart:970:10)
#2      RenderObject._paintWithContext (package:flutter/src/rendering/object.dart:2311:7)
#3      PaintingContext.paintChild (package:flutter/src/rendering/object.dart:189:13)
#4      RenderBoxContainerDefaultsMixin.defaultPaint (package:flutter/src/rendering/box.dart:2616:15)
...
The following RenderObject was being processed when the exception was fired: RenderFlex#ca889 relayoutBoundary=up4
...  needs compositing
...  parentData: offset=Offset(0.0, 0.0); id=_ScaffoldSlot.body (can use size)
...  constraints: BoxConstraints(0.0<=w<=423.5, 0.0<=h<=720.1)
...  size: MISSING
...  direction: vertical
...  mainAxisAlignment: start
...  mainAxisSize: max
...  crossAxisAlignment: center
...  verticalDirection: down
RenderObject: RenderFlex#ca889 relayoutBoundary=up4
  needs compositing
  parentData: offset=Offset(0.0, 0.0); id=_ScaffoldSlot.body (can use size)
  constraints: BoxConstraints(0.0<=w<=423.5, 0.0<=h<=720.1)
  size: MISSING
  direction: vertical
  mainAxisAlignment: start
  mainAxisSize: max
  crossAxisAlignment: center
  verticalDirection: down
...  child 1: RenderPositionedBox#263fc NEEDS-LAYOUT NEEDS-PAINT
...    parentData: offset=Offset(0.0, 0.0); flex=1; fit=FlexFit.tight
...    constraints: MISSING
...    size: MISSING
...    alignment: center
...    textDirection: ltr
...    widthFactor: expand
...    heightFactor: expand
...    child: RenderSemanticsAnnotations#87544 NEEDS-LAYOUT NEEDS-PAINT
...      parentData: offset=Offset(0.0, 0.0)
...      constraints: MISSING
...      size: MISSING
...      child: RenderConstrainedBox#26d04 NEEDS-LAYOUT NEEDS-PAINT
...        parentData: <none>
...        constraints: MISSING
...        size: MISSING
...        additionalConstraints: BoxConstraints(36.0<=w<=Infinity, 36.0<=h<=Infinity)
...        child: RenderCustomPaint#3ac7e NEEDS-LAYOUT NEEDS-PAINT
...          parentData: <none>
...          constraints: MISSING
...          size: MISSING
...  child 2: RenderConstrainedBox#97ac3 relayoutBoundary=up5 NEEDS-LAYOUT NEEDS-PAINT
...    needs compositing
...    parentData: offset=Offset(0.0, 0.0); flex=null; fit=null (can use size)
...    constraints: BoxConstraints(0.0<=w<=423.5, 0.0<=h<=Infinity)
...    size: MISSING
...    additionalConstraints: BoxConstraints(w=Infinity, 0.0<=h<=Infinity)
...    child: _RenderColoredBox#50f62 relayoutBoundary=up6 NEEDS-LAYOUT NEEDS-PAINT
...      needs compositing
...      parentData: <none> (can use size)
...      constraints: BoxConstraints(w=423.5, 0.0<=h<=Infinity)
...      size: MISSING
...      behavior: opaque
...      child: RenderPadding#f4661 relayoutBoundary=up7 NEEDS-LAYOUT NEEDS-PAINT
...        needs compositing
...        parentData: <none> (can use size)
...        constraints: BoxConstraints(w=423.5, 0.0<=h<=Infinity)
...        size: MISSING
...        padding: EdgeInsets.all(10.0)
...        textDirection: ltr
...        child: RenderFlex#0a1f3 relayoutBoundary=up8 NEEDS-LAYOUT NEEDS-PAINT
...          needs compositing
...          parentData: offset=Offset(10.0, 10.0) (can use size)
...          constraints: BoxConstraints(w=403.5, 0.0<=h<=Infinity)
...          size: MISSING
...          direction: horizontal
...          mainAxisAlignment: start
...          mainAxisSize: max
...          crossAxisAlignment: center
...          textDirection: ltr
...          verticalDirection: down
...          textBaseline: alphabetic

我想要做的是,当满足特定条件时,我想在 TextField 上堆叠一个容器。谢谢。

0 个答案:

没有答案