当前位置: 首页 > 知识库问答 >
问题:

使用Targetplatform会导致布局问题

唐健
2023-03-14

我正在试着检查用户是在Iphone上还是在Android上

typeOfDevice = Theme.of(context).platform == TargetPlatform.iOS
        ? "1"
        : "2";
I/flutter (22330): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (22330): The following assertion was thrown building MediaQuery(MediaQueryData(size: Size(360.0, 640.0),
I/flutter (22330): devicePixelRatio: 2.0, textScaleFactor: 1.0, padding: EdgeInsets(0.0, 24.0, 0.0, 0.0), viewInsets:
I/flutter (22330): EdgeInsets.zero, alwaysUse24HourFormat: false, accessibleNavigation: falsedisableAnimations:
I/flutter (22330): falseinvertColors: falseboldText: false)):
I/flutter (22330): inheritFromWidgetOfExactType(_InheritedTheme) or inheritFromElement() was called before
I/flutter (22330): _EnterOtpLoginState.initState() completed.
I/flutter (22330): When an inherited widget changes, for example if the value of Theme.of() changes, its dependent
I/flutter (22330): widgets are rebuilt. If the dependent widget's reference to the inherited widget is in a constructor
I/flutter (22330): or an initState() method, then the rebuilt dependent widget will not reflect the changes in the
I/flutter (22330): inherited widget.
I/flutter (22330): Typically references to to inherited widgets should occur in widget build() methods. Alternatively,
I/flutter (22330): initialization based on inherited widgets can be placed in the didChangeDependencies method, which
I/flutter (22330): is called after initState and whenever the dependencies change thereafter.
I/flutter (22330): When the exception was thrown, this was the stack:
I/flutter (22330): #0      StatefulElement.inheritFromElement.<anonymous closure> (package:flutter/src/widgets/framework.dart:3920:9)
I/flutter (22330): #1      StatefulElement.inheritFromElement (package:flutter/src/widgets/framework.dart:3953:6)
I/flutter (22330): #2      Element.inheritFromWidgetOfExactType (package:flutter/src/widgets/framework.dart:3274:14)
I/flutter (22330): #3      Theme.of (package:flutter/src/material/theme.dart:127:52)
I/flutter (22330): #4      _EnterOtpLoginState.initState (package:dice_clutter/screens/otp_login/otp_login.dart:126:26)
I/flutter (22330): #5      StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3830:58)
I/flutter (22330): #6      ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (22330): #7      Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #8      MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4965:32)
I/flutter (22330): #9      Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #10     MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4965:32)
I/flutter (22330): #11     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #12     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #13     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #14     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #15     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (22330): #16     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (22330): #17     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #18     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #19     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #20     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #21     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (22330): #22     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (22330): #23     ParentDataElement.mount (package:flutter/src/widgets/framework.dart:4047:11)
I/flutter (22330): #24     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #25     MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4965:32)
I/flutter (22330): #26     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #27     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #28     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #29     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #30     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (22330): #31     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (22330): #32     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (22330): #33     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #34     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #35     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #36     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #37     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (22330): #38     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (22330): #39     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #40     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #41     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #42     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #43     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (22330): #44     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (22330): #45     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (22330): #46     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #47     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #48     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (22330): #49     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #50     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #51     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #52     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #53     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (22330): #54     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (22330): #55     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #56     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #57     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (22330): #58     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #59     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #60     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #61     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #62     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (22330): #63     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (22330): #64     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (22330): #65     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #66     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #67     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #68     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #69     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (22330): #70     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (22330): #71     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (22330): #72     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #73     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #74     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #75     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #76     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (22330): #77     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (22330): #78     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #79     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #80     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #81     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #82     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (22330): #83     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (22330): #84     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #85     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #86     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #87     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #88     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (22330): #89     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (22330): #90     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (22330): #91     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #92     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #93     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #94     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #95     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (22330): #96     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (22330): #97     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (22330): #98     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #99     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #100    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #101    Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #102    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (22330): #103    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (22330): #104    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #105    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #106    SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (22330): #107    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #108    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #109    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #110    Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #111    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (22330): #112    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (22330): #113    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #114    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #115    SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (22330): #116    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #117    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #118    SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (22330): #119    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #120    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #121    SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (22330): #122    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #123    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #124    SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (22330): #125    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #126    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #127    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #128    Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #129    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (22330): #130    StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (22330): #131    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (22330): #132    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #133    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #134    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #135    Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #136    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (22330): #137    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (22330): #138    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #139    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #140    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #141    Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #142    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (22330): #143    StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (22330): #144    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (22330): #145    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #146    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #147    SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (22330): #148    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #149    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #150    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #151    Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #152    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (22330): #153    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (22330): #154    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #155    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #156    SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (22330): #157    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #158    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #159    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #160    Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #161    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (22330): #162    StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (22330): #163    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (22330): #164    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #165    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #166    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #167    Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #168    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (22330): #169    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (22330): #170    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #171    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #172    SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter (22330): #173    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #174    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #175    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #176    Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #177    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (22330): #178    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (22330): #179    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #180    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #181    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #182    Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #183    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (22330): #184    StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (22330): #185    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (22330): #186    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #187    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #188    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #189    Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #190    ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter (22330): #191    StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter (22330): #192    ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter (22330): #193    Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter (22330): #194    Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter (22330): #195    RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:4643:32)
I/flutter (22330): #196    MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4975:17)
I/flutter (22330): #197    Element.updateChild (package:flutter/src/widgets/framework.dart:2742:15)
I/flutter (22330): #198    _TheatreElement.update (package:flutter/src/widgets/overlay.dart:507:16)
I/flutter (22330): #199    Element.updateChild (package:flutter/src/widgets/framework.dart:2742:15)
I/flutter (22330): #200    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #201    Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #202    StatefulElement.update (package:flutter/src/widgets/framework.dart:3878:5)
I/flutter (22330): #203    Element.updateChild (package:flutter/src/widgets/framework.dart:2742:15)
I/flutter (22330): #204    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #205    Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #206    ProxyElement.update (package:flutter/src/widgets/framework.dart:3990:5)
I/flutter (22330): #207    Element.updateChild (package:flutter/src/widgets/framework.dart:2742:15)
I/flutter (22330): #208    SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4867:14)
I/flutter (22330): #209    Element.updateChild (package:flutter/src/widgets/framework.dart:2742:15)
I/flutter (22330): #210    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #211    Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #212    StatefulElement.update (package:flutter/src/widgets/framework.dart:3878:5)
I/flutter (22330): #213    Element.updateChild (package:flutter/src/widgets/framework.dart:2742:15)
I/flutter (22330): #214    SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4867:14)
I/flutter (22330): #215    Element.updateChild (package:flutter/src/widgets/framework.dart:2742:15)
I/flutter (22330): #216    SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4867:14)
I/flutter (22330): #217    Element.updateChild (package:flutter/src/widgets/framework.dart:2742:15)
I/flutter (22330): #218    ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter (22330): #219    Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter (22330): #220    BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2286:33)
I/flutter (22330): #221    _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:676:20)
I/flutter (22330): #222    _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:219:5)
I/flutter (22330): #223    _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990:15)
I/flutter (22330): #224    _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:930:9)
I/flutter (22330): #225    _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:842:5)
I/flutter (22330): #226    _invoke (dart:ui/hooks.dart:154:13)
I/flutter (22330): #227    _drawFrame (dart:ui/hooks.dart:143:3)
I/flutter (22330): ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter (22330): Another exception was thrown: The _ScaffoldLayout custom multichild layout delegate forgot to lay out the following child:
I/flutter (22330): Another exception was thrown: inheritFromWidgetOfExactType(_InheritedTheme) or inheritFromElement() was called before _EnterOtpLoginState.initState() completed.
I/flutter (22330): Another exception was thrown: The _ScaffoldLayout custom multichild layout delegate forgot to lay out the following children:

当我注释这行代码时,应用程序运行良好

共有1个答案

钱和安
2023-03-14

出现此问题是因为您试图从initstate获取Inheritedwidget。这是故意不可能的

而是使用DidChangeDependencies:

didChangeDependencies() {
  typeOfDevice = Theme.of(context).platform == TargetPlatform.iOS
} 
 类似资料:
  • 问题内容: 我正在尝试使用行高和单元格的自动布局来制作可扩展单元格。为了使事情变得简单,我从下面的简单代码开始,我希望它们能正常工作: 现在这似乎可行,但是,我仍然收到以下消息警告: 估计(或当前)行高似乎与我提供的自动布局约束相冲突。尽管如此,使用以下代码刷新tableView仍将按预期显示它: 如何删除警告? 我知道将高度限制的优先级简单地更改为999即可删除警告,但在我看来,删除警告是一种h

  • 我在Windows 10中使用cmake构建了一个C项目(Visual Studio 2019,尽管它只使用了构建工具而不是GUI,实际使用的编译器是clang)。如果我在没有编译器优化的情况下构建它,它会构建得很好,但是如果我使用< code > set(CMAKE _ CXX _ FLAGS _ RELEASE“-O3”)传递< code>-O3,那么编译后的二进制文件会有某种权限问题。cte

  • 我需要制作一个顶部带有静态视图的可滚动片段,底部每个页面都带有RecyclerView的ViewPager。我正在尝试使用CoordinatorLayout来实现所需的结果,但遇到了一个问题——当我向上(为了向下滚动)抛出俯视图,然后在向下(为了向上滚动)抛出RecyclerView后不久,滚动就有点抵消和抖动;当我第一次将RecyclerView向下,然后将俯视图向上时,整个片段会滚动到顶部。当

  • 以下操作会在运行时导致异常: java.lang.VerifyError:操作数堆栈上的类型错误异常详细信息:location:com/sun/net/httpserver/spi/httpserverprovider$1.run()ljava/lang/object;@27:invokestatic原因:类型“sun/net/httpserver/defaulthttpserverprovide

  • 几个小时以来,我们一直试图让MUI DataGrid正常工作,但出于某种原因,样式将分页信息放在表的顶部,列标题的顶部。也许这是我在做的蠢事。我尝试了一个非常简单的版本来说明我的问题。希望有人能帮助我。顺便说一句,我使用MUI和DataGrid的v5。反应是v17 输出如下所示。 因此,您可以看到,应该显示在表数据下方的分页部分反而位于页面顶部。事实上,应该围绕数据的边框也被移动到顶部。我希望有人

  • 我试图升级我目前的java项目,运行在1.6到1.8,但程序编译良好如何曾经当我去http://localhost:8080/MyProject/login.jsp-我得到错误。 我正在使用eclipse luna,我将java\u HOME更改为1.8,将eclipse项目facets更改为1.8,并更新了javax。servlet api=3.1.0。 堆栈跟踪 无布局。jsp 我用常春藤做依