Android Studio 得到了这个错误“一个RenderFlex溢出了99932像素的底部”

bbuxkriu  于 2022-11-25  发布在  Android
关注(0)|答案(3)|浏览(179)

我正在学习2019年的flutter课程(老师用清晰的解释和切实的例子解释每一个概念),但由于flutter版本的差异和我对移动的应用程序开发完全是新手,我总是会出错。
这一次我找不到一个可以帮助我的答案,所以我决定在这里问自己的第一次。
这是我得到的全部错误

======== Exception caught by widgets library =======================================================
The following assertion was thrown building RoundIconButton(dirty):
setState() or markNeedsBuild() called during build.

This InputPage widget cannot be marked as needing to build because the framework is already in the process of building widgets. A widget can be marked as needing to be built during the build phase only if one of its ancestors is currently building. This exception is allowed because the framework builds parent widgets before children, which means a dirty descendant will always be built. Otherwise, the framework might not visit this widget during this build phase.
The widget on which setState() or markNeedsBuild() was called was: InputPage
  dependencies: [_InheritedTheme, _LocalizationsScope-[GlobalKey#9665e]]
  state: _InputPageState#b079c
The widget which was currently being built when the offending call was made was: RoundIconButton
  dirty
The relevant error-causing widget was: 
  RoundIconButton RoundIconButton:file:///C:/Users/murod/StudioProjects/bmi_calculator/lib/input_page.dart:144:29
When the exception was thrown, this was the stack: 
#0      Element.markNeedsBuild.<anonymous closure> (package:flutter/src/widgets/framework.dart:4424:11)
#1      Element.markNeedsBuild (package:flutter/src/widgets/framework.dart:4439:6)
#2      State.setState (package:flutter/src/widgets/framework.dart:1141:15)
#3      _InputPageState.build.<anonymous closure> (package:bmi_calculator/input_page.dart:147:33)
#4      RoundIconButton.build (package:bmi_calculator/input_page.dart:193:27)
#5      StatelessElement.build (package:flutter/src/widgets/framework.dart:4827:28)
#6      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4754:15)
#7      Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#8      StatelessElement.update (package:flutter/src/widgets/framework.dart:4834:5)
#9      Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#10     RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:5787:32)
#11     MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6445:17)
#12     Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#13     RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:5787:32)
#14     MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6445:17)
#15     Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#16     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6291:14)
#17     Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#18     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6291:14)
#19     Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#20     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#21     Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#22     StatelessElement.update (package:flutter/src/widgets/framework.dart:4834:5)
#23     Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#24     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6291:14)
#25     Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#26     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6291:14)
#27     Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#28     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#29     StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4928:11)
#30     Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#31     StatefulElement.update (package:flutter/src/widgets/framework.dart:4960:5)
#32     Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#33     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#34     Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#35     StatelessElement.update (package:flutter/src/widgets/framework.dart:4834:5)
#36     Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#37     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#38     Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#39     StatelessElement.update (package:flutter/src/widgets/framework.dart:4834:5)
#40     Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#41     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#42     Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#43     ProxyElement.update (package:flutter/src/widgets/framework.dart:5108:5)
#44     Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#45     RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:5787:32)
#46     MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6445:17)
#47     Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#48     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#49     Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#50     ProxyElement.update (package:flutter/src/widgets/framework.dart:5108:5)
#51     Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#52     RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:5787:32)
#53     MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6445:17)
#54     Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#55     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#56     Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#57     StatelessElement.update (package:flutter/src/widgets/framework.dart:4834:5)
#58     Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#59     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#60     Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#61     ProxyElement.update (package:flutter/src/widgets/framework.dart:5108:5)
#62     Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#63     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#64     Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#65     ProxyElement.update (package:flutter/src/widgets/framework.dart:5108:5)
#66     Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#67     RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:5787:32)
#68     MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6445:17)
#69     Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#70     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#71     StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4928:11)
#72     Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#73     StatefulElement.update (package:flutter/src/widgets/framework.dart:4960:5)
#74     Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#75     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#76     Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#77     ProxyElement.update (package:flutter/src/widgets/framework.dart:5108:5)
#78     Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#79     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#80     StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4928:11)
#81     Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#82     StatefulElement.update (package:flutter/src/widgets/framework.dart:4960:5)
#83     Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#84     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6291:14)
#85     Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#86     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#87     Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#88     StatelessElement.update (package:flutter/src/widgets/framework.dart:4834:5)
#89     Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#90     SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6291:14)
#91     Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#92     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#93     StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4928:11)
#94     Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#95     StatefulElement.update (package:flutter/src/widgets/framework.dart:4960:5)
#96     Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#97     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#98     StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4928:11)
#99     Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#100    StatefulElement.update (package:flutter/src/widgets/framework.dart:4960:5)
#101    Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#102    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#103    Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#104    ProxyElement.update (package:flutter/src/widgets/framework.dart:5108:5)
#105    Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#106    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#107    Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#108    StatelessElement.update (package:flutter/src/widgets/framework.dart:4834:5)
#109    Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#110    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#111    StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4928:11)
#112    Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#113    StatefulElement.update (package:flutter/src/widgets/framework.dart:4960:5)
#114    Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#115    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#116    Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#117    ProxyElement.update (package:flutter/src/widgets/framework.dart:5108:5)
#118    Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#119    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#120    StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4928:11)
#121    Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#122    StatefulElement.update (package:flutter/src/widgets/framework.dart:4960:5)
#123    Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#124    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#125    StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4928:11)
#126    Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#127    StatefulElement.update (package:flutter/src/widgets/framework.dart:4960:5)
#128    Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#129    SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6291:14)
#130    Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#131    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#132    Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#133    StatelessElement.update (package:flutter/src/widgets/framework.dart:4834:5)
#134    Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#135    SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6291:14)
#136    Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#137    SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6291:14)
#138    Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#139    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#140    StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4928:11)
#141    Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#142    StatefulElement.update (package:flutter/src/widgets/framework.dart:4960:5)
#143    Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#144    SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6291:14)
#145    Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#146    SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6291:14)
#147    Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#148    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#149    StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4928:11)
#150    Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#151    StatefulElement.update (package:flutter/src/widgets/framework.dart:4960:5)
#152    Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#153    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#154    Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#155    StatelessElement.update (package:flutter/src/widgets/framework.dart:4834:5)
#156    Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#157    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#158    StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4928:11)
#159    Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#160    StatefulElement.update (package:flutter/src/widgets/framework.dart:4960:5)
#161    Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#162    SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6291:14)
#163    Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#164    SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6291:14)
#165    Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#166    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#167    Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#168    ProxyElement.update (package:flutter/src/widgets/framework.dart:5108:5)
#169    _InheritedNotifierElement.update (package:flutter/src/widgets/inherited_notifier.dart:111:11)
#170    Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#171    SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6291:14)
#172    Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#173    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#174    StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4928:11)
#175    Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#176    StatefulElement.update (package:flutter/src/widgets/framework.dart:4960:5)
#177    Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#178    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#179    Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#180    ProxyElement.update (package:flutter/src/widgets/framework.dart:5108:5)
#181    Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#182    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#183    Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#184    ProxyElement.update (package:flutter/src/widgets/framework.dart:5108:5)
#185    Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#186    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#187    StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4928:11)
#188    Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#189    StatefulElement.update (package:flutter/src/widgets/framework.dart:4960:5)
#190    Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#191    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#192    Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#193    StatelessElement.update (package:flutter/src/widgets/framework.dart:4834:5)
#194    Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#195    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#196    Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#197    StatelessElement.update (package:flutter/src/widgets/framework.dart:4834:5)
#198    Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#199    SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:6291:14)
#200    Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#201    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#202    Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#203    ProxyElement.update (package:flutter/src/widgets/framework.dart:5108:5)
#204    Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#205    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#206    Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#207    ProxyElement.update (package:flutter/src/widgets/framework.dart:5108:5)
#208    Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#209    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#210    StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4928:11)
#211    Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#212    StatefulElement.update (package:flutter/src/widgets/framework.dart:4960:5)
#213    Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#214    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#215    StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4928:11)
#216    Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#217    StatefulElement.update (package:flutter/src/widgets/framework.dart:4960:5)
#218    Element.updateChild (package:flutter/src/widgets/framework.dart:3501:15)
#219    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:4780:16)
#220    StatefulElement.performRebuild (package:flutter/src/widgets/framework.dart:4928:11)
#221    Element.rebuild (package:flutter/src/widgets/framework.dart:4477:5)
#222    BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2659:19)
#223    WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:882:21)
#224    RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:363:5)
#225    SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1144:15)
#226    SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:1081:9)
#227    SchedulerBinding.scheduleWarmUpFrame.<anonymous closure> (package:flutter/src/scheduler/binding.dart:862:7)
(elided 4 frames from class _RawReceivePortImpl, class _Timer, and dart:async-patch)
====================================================================================================

======== Exception caught by rendering library =====================================================
The following assertion was thrown during layout:
A RenderFlex overflowed by 199834 pixels on the right.

The relevant error-causing widget was: 
  Row Row:file:///C:/Users/murod/StudioProjects/bmi_calculator/lib/input_page.dart:130:25
The overflowing RenderFlex has an orientation of Axis.horizontal.
The edge of the RenderFlex that is overflowing has been marked in the rendering with a yellow and black striped pattern. This is usually caused by the contents being too big for the RenderFlex.

Consider applying a flex factor (e.g. using an Expanded widget) to force the children of the RenderFlex to fit within the available space instead of being sized to their natural size.
This is considered an error condition because it indicates that there is content that cannot be seen. If the content is legitimately bigger than the available space, consider clipping it with a ClipRect widget before putting it in the flex, or using a scrollable container rather than a Flex, like a ListView.

The specific RenderFlex in question is: RenderFlex#80ab8 relayoutBoundary=up6 OVERFLOWING
...  parentData: offset=Offset(0.0, 80.0); flex=null; fit=null (can use size)
...  constraints: BoxConstraints(0.0<=w<=175.7, 0.0<=h<=Infinity)
...  size: Size(175.7, 100000.0)
...  direction: horizontal
...  mainAxisAlignment: center
...  mainAxisSize: max
...  crossAxisAlignment: center
...  textDirection: ltr
...  verticalDirection: down
  child 1: RenderErrorBox#4a268
    parentData: offset=Offset(0.0, 0.0); flex=null; fit=null (can use size)
    constraints: BoxConstraints(unconstrained)
    size: Size(100000.0, 100000.0)
  child 2: RenderConstrainedBox#12f15 relayoutBoundary=up7
    parentData: offset=Offset(100000.0, 50000.0); flex=null; fit=null (can use size)
    constraints: BoxConstraints(unconstrained)
    size: Size(10.0, 0.0)
    additionalConstraints: BoxConstraints(w=10.0, 0.0<=h<=Infinity)
  child 3: RenderErrorBox#9a119
    parentData: offset=Offset(100010.0, 0.0); flex=null; fit=null (can use size)
    constraints: BoxConstraints(unconstrained)
    size: Size(100000.0, 100000.0)
◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤
====================================================================================================

======== Exception caught by rendering library =====================================================
The following assertion was thrown during layout:
A RenderFlex overflowed by 99932 pixels on the bottom.

The relevant error-causing widget was: 
  Column Column:file:///C:/Users/murod/StudioProjects/bmi_calculator/lib/input_page.dart:121:32
The overflowing RenderFlex has an orientation of Axis.vertical.
The edge of the RenderFlex that is overflowing has been marked in the rendering with a yellow and black striped pattern. This is usually caused by the contents being too big for the RenderFlex.

Consider applying a flex factor (e.g. using an Expanded widget) to force the children of the RenderFlex to fit within the available space instead of being sized to their natural size.
This is considered an error condition because it indicates that there is content that cannot be seen. If the content is legitimately bigger than the available space, consider clipping it with a ClipRect widget before putting it in the flex, or using a scrollable container rather than a Flex, like a ListView.

The specific RenderFlex in question is: RenderFlex#5a9a0 relayoutBoundary=up5 OVERFLOWING
...  parentData: <none> (can use size)
...  constraints: BoxConstraints(w=175.7, 0.0<=h<=147.8)
...  size: Size(175.7, 147.8)
...  direction: vertical
...  mainAxisAlignment: center
...  mainAxisSize: min
...  crossAxisAlignment: center
...  verticalDirection: down
◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤◢◤
====================================================================================================

这是错误所表示的来源代码(一切都是从我添加onPressed开始的。在此之前,没有错误)

Column(
                  mainAxisSize: MainAxisSize.min,
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    Text('WEIGHT', style: kLabelTextStyle),
                    Text(
                      weight.toString(),
                      style: kNumberTextStyle,
                    ),
                    Row(
                      mainAxisAlignment: MainAxisAlignment.center,
                      children: [
                        RoundIconButton(
                          icon: FontAwesomeIcons.minus,
                          onPressed: () {
                            setState(() {
                              weight--;
                            });
                          },
                        ),
                        const SizedBox(
                          width: 10,
                        ),
                        RoundIconButton(
                          icon: FontAwesomeIcons.plus,
                          onPressed: () {
                            setState(() {
                              weight++;
                            });
                          },
                        ),
                      ],
                    )
                  ],
                )

下面是RoundIconButton代码:

class RoundIconButton extends StatelessWidget {
  RoundIconButton({required this.icon, required this.onPressed});

  final IconData icon;
  final Function onPressed;

  @override
  Widget build(BuildContext context) {
    return RawMaterialButton(
      child: Icon(icon),
      constraints: const BoxConstraints.tightFor(width: 55, height: 55),
      shape: const CircleBorder(),
      fillColor: const Color(0xFF4C4F5E),
      onPressed: onPressed(),
    );
  }
}

谢谢你的帮忙

3hvapo4f

3hvapo4f1#

显然您键入了一些额外的字符,请尝试此操作。

onPressed: () {
setState(){  weight++;  };
},
qpgpyjmq

qpgpyjmq2#

我用“”和“”来表示代码中的更改位置
解决方案只是改变

class RoundIconButton extends StatelessWidget {
  RoundIconButton({required this.icon, required this.onPressed});

     final IconData icon;
  ➡ final Function onPressed; ⬅

  @override
  Widget build(BuildContext context) {
    return RawMaterialButton(
      child: Icon(icon),
      constraints: const BoxConstraints.tightFor(width: 55, height: 55),
      shape: const CircleBorder(),
      fillColor: const Color(0xFF4C4F5E),
   ➡ onPressed: onPressed(), ⬅
    );
  }
}

class RoundIconButton extends StatelessWidget {
  RoundIconButton({required this.icon, required this.onPressed});

    final IconData icon;
 ➡ final Function() onPressed; ⬅

  @override
  Widget build(BuildContext context) {
    return RawMaterialButton(
      child: Icon(icon),
      constraints: const BoxConstraints.tightFor(width: 55, height: 55),
      shape: const CircleBorder(),
      fillColor: const Color(0xFF4C4F5E),
  ➡  onPressed: onPressed,  ⬅
    );
  }
}

变更添加到“final Function**()**onPressed;“
并删除“onPressed:按下,”

ijnw1ujt

ijnw1ujt3#

类RoundIconButton扩展了StatelessWidget { RoundIconButton({需要此.icon,需要此.onPressed});
最终IconData图标;最后一个VoidCallbackon按下;

相关问题