flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
166.33k stars 27.53k forks source link

No Material widget found error but Scaffold present #28326

Closed opensourcegps closed 5 years ago

opensourcegps commented 5 years ago

Steps to Reproduce

Following code will blink the error (red box) on the screen for 0.5 sec and then everything becomes normal:

 return new Scaffold(        
        appBar: new CupertinoNavigationBar(
          middle: new Text('test'),
          trailing: IconButton(icon: Icon(Icons.settings)),      
        ),

        body: Text('test'),
);

Logs

I/flutter ( 4498): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter ( 4498): The following assertion was thrown building IconButton(Icon, disabled, dirty):
I/flutter ( 4498): No Material widget found.
I/flutter ( 4498): IconButton widgets require a Material widget ancestor.
I/flutter ( 4498): In material design, most widgets are conceptually "printed" on a sheet of material. In Flutter's
I/flutter ( 4498): material library, that material is represented by the Material widget. It is the Material widget
I/flutter ( 4498): that renders ink splashes, for instance. Because of this, many material library widgets require that
I/flutter ( 4498): there be a Material widget in the tree above them.
I/flutter ( 4498): To introduce a Material widget, you can either directly include one, or use a widget that contains
I/flutter ( 4498): Material itself, such as a Card, Dialog, Drawer, or Scaffold.
I/flutter ( 4498): The specific widget that could not find a Material ancestor was:
I/flutter ( 4498):   IconButton(Icon, disabled)
I/flutter ( 4498): The ancestors of this widget were:
I/flutter ( 4498):   IconTheme(IconThemeData#330fb(color: Color(0xff007aff), size: 32.0))
I/flutter ( 4498):   Builder
I/flutter ( 4498):   DefaultTextStyle(inherit: true, color: Color(0xff007aff), family: .SF UI Text, size: 17.0,
I/flutter ( 4498):   letterSpacing: -0.2, softWrap: wrapping at box width, overflow: clip)
I/flutter ( 4498):   Padding(padding: EdgeInsetsDirectional(0.0, 0.0, 16.0, 0.0))
I/flutter ( 4498):   FadeTransition(opacity: AnimationController#68b93(◀ 0.549; for
I/flutter ( 4498):   MaterialPageRoute<dynamic>(/calendar_event))➩ProxyAnimation➩Cubic(0.40, 0.00, 0.20,
I/flutter ( 4498):   1.00)➩CurveTween(curve: Interval(0.4⋯1.0)➩Cubic(0.42, 0.00, 1.00, 1.00))➩Tween<double>(0.0 →
I/flutter ( 4498):   1.0)➩0.5788082629442215)
I/flutter ( 4498):   Positioned(left: 347.4, top: 24.0, right: 0.0, bottom: 0.0)
I/flutter ( 4498):   Stack(alignment: AlignmentDirectional.topStart, fit: loose, overflow: clip)
I/flutter ( 4498):   SizedBox(width: Infinity, height: 92.0)
I/flutter ( 4498):   _NavigationBarTransition
I/flutter ( 4498):   Opacity(opacity: 1.0)
I/flutter ( 4498):   RepaintBoundary
I/flutter ( 4498):   IgnorePointer(ignoring: true)
I/flutter ( 4498):   Positioned(left: 0.0, top: 0.0, right: 0.0, bottom: 663.4)
I/flutter ( 4498):   AnimatedBuilder(animation: AnimationController#68b93(◀ 0.549; for
I/flutter ( 4498):   MaterialPageRoute<dynamic>(/calendar_event))➩ProxyAnimation➩Cubic(0.40, 0.00, 0.20,
I/flutter ( 4498):   1.00)➪ReverseAnimation➩ProxyAnimation)
I/flutter ( 4498):   _OverlayEntry-[LabeledGlobalKey<_OverlayEntryState>#8b810]
I/flutter ( 4498):   Stack(alignment: AlignmentDirectional.topStart, fit: expand, overflow: clip)
I/flutter ( 4498):   _Theatre
I/flutter ( 4498):   Overlay-[LabeledGlobalKey<OverlayState>#22026]
I/flutter ( 4498):   _FocusScopeMarker
I/flutter ( 4498):   Semantics(container: false, properties: SemanticsProperties, label: null, value: null, hint: null,
I/flutter ( 4498):   hintOverrides: null)
I/flutter ( 4498):   FocusScope
I/flutter ( 4498):   AbsorbPointer(absorbing: false)
I/flutter ( 4498):   Listener(listeners: [down, up, cancel], behavior: deferToChild)
I/flutter ( 4498):   Navigator-[GlobalObjectKey<NavigatorState> _WidgetsAppState#b3969]
I/flutter ( 4498):   DefaultTextStyle(debugLabel: fallback style; consider putting your text in a Material, inherit:
I/flutter ( 4498):   true, color: Color(0xd0ff0000), family: monospace, size: 48.0, weight: 900, decoration: double
I/flutter ( 4498):   Color(0xffffff00) TextDecoration.underline, softWrap: wrapping at box width, overflow: clip)
I/flutter ( 4498):   Title(title: "App", color: Color(0xff5a8dd2))
I/flutter ( 4498):   Directionality(textDirection: ltr)
I/flutter ( 4498):   _LocalizationsScope-[GlobalKey#221d2]
I/flutter ( 4498):   Semantics(container: false, properties: SemanticsProperties, label: null, value: null, hint: null,
I/flutter ( 4498):   textDirection: ltr, hintOverrides: null)
I/flutter ( 4498):   Localizations(locale: en_US, delegates: [AppLocalizationsDelegate[AppLocalizations],
I/flutter ( 4498):   GlobalMaterialLocalizations.delegate(49 locales), GlobalWidgetsLocalizations.delegate(all
I/flutter ( 4498):   locales), FallbackCupertinoLocalisationsDelegate[CupertinoLocalizations],
I/flutter ( 4498):   DefaultMaterialLocalizations.delegate(en_US), DefaultCupertinoLocalizations.delegate(en_US),
I/flutter ( 4498):   DefaultWidgetsLocalizations.delegate(en_US)])
I/flutter ( 4498):   MediaQuery(MediaQueryData(size: Size(411.4, 731.4), devicePixelRatio: 2.6, textScaleFactor: 1.0,
I/flutter ( 4498):   padding: EdgeInsets(0.0, 24.0, 0.0, 0.0), viewInsets: EdgeInsets.zero, alwaysUse24HourFormat:
I/flutter ( 4498):   false, accessibleNavigation: falsedisableAnimations: falseinvertColors: falseboldText: false))
I/flutter ( 4498):   WidgetsApp-[GlobalObjectKey _MaterialAppState#ea039]
I/flutter ( 4498):   IconTheme(IconThemeData#2abdc(color: Color(0xdd000000)))
I/flutter ( 4498):   _InheritedTheme
I/flutter ( 4498):   Theme(ThemeData#aff1e(primaryColor: Color(0xff5a8dd2), accentColor: Color(0xff5a8dd2),
I/flutter ( 4498):   indicatorColor: Color(0xffffffff), toggleableActiveColor: Color(0xff5a8dd2), buttonTheme:
I/flutter ( 4498):   ButtonThemeData#6c309(buttonColor: Color(0xffe0e0e0), colorScheme: ColorScheme#6dedb(primary:
I/flutter ( 4498):   MaterialColor(primary value: Color(0xff2196f3)), primaryVariant: Color(0xff1976d2), secondary:
I/flutter ( 4498):   Color(0xff5a8dd2), secondaryVariant: Color(0xff1976d2), background: Color(0xff90caf9), error:
I/flutter ( 4498):   Color(0xffd32f2f), onSecondary: Color(0xffffffff), onBackground: Color(0xffffffff)),
I/flutter ( 4498):   materialTapTargetSize: MaterialTapTargetSize.padded), textTheme: TextTheme#204ed,
I/flutter ( 4498):   primaryTextTheme: TextTheme#ef275(display4: TextStyle(debugLabel: whiteMountainView display4,
I/flutter ( 4498):   inherit: true, color: Color(0xb3ffffff), family: Roboto, decoration: TextDecoration.none),
I/flutter ( 4498):   display3: TextStyle(debugLabel: whiteMountainView display3, inherit: true, color:
I/flutter ( 4498):   Color(0xb3ffffff), family: Roboto, decoration: TextDecoration.none), display2:
I/flutter ( 4498):   TextStyle(debugLabel: whiteMountainView display2, inherit: true, color: Color(0xb3ffffff), family:
I/flutter ( 4498):   Roboto, decoration: TextDecoration.none), display1: TextStyle(debugLabel: whiteMountainView
I/flutter ( 4498):   display1, inherit: true, color: Color(0xb3ffffff), family: Roboto, decoration:
I/flutter ( 4498):   TextDecoration.none), headline: TextStyle(debugLabel: whiteMountainView headline, inherit: true,
I/flutter ( 4498):   color: Color(0xffffffff), family: Roboto, decoration: TextDecoration.none), title:
I/flutter ( 4498):   TextStyle(debugLabel: whiteMountainView title, inherit: true, color: Color(0xffffffff), family:
I/flutter ( 4498):   Roboto, decoration: TextDecoration.none), subhead: TextStyle(debugLabel: whiteMountainView
I/flutter ( 4498):   subhead, inherit: true, color: Color(0xffffffff), family: Roboto, decoration:
I/flutter ( 4498):   TextDecoration.none), body2: TextStyle(debugLabel: whiteMountainView body2, inherit: true, color:
I/flutter ( 4498):   Color(0xffffffff), family: Roboto, decoration: TextDecoration.none), body1: TextStyle(debugLabel:
I/flutter ( 4498):   whiteMountainView body1, inherit: true, color: Color(0xffffffff), family: Roboto, decoration:
I/flutter ( 4498):   TextDecoration.none), caption: TextStyle(debugLabel: whiteMountainView caption, inherit: true,
I/flutter ( 4498):   color: Color(0xb3ffffff), family: Roboto, decoration: TextDecoration.none), button:
I/flutter ( 4498):   TextStyle(debugLabel: whiteMountainView button, inherit: true, color: Color(0xffffffff), family:
I/flutter ( 4498):   Roboto, decoration: TextDecoration.none), subtitle): TextStyle(debugLabel: whiteMountainView
I/flutter ( 4498):   subtitle, inherit: true, color: Color(0xffffffff), family: Roboto, decoration:
I/flutter ( 4498):   TextDecoration.none), overline: TextStyle(debugLabel: whiteMountainView overline, inherit: true,
I/flutter ( 4498):   color: Color(0xffffffff), family: Roboto, decoration: TextDecoration.none)), accentTextTheme:
I/flutter ( 4498):   TextTheme#ef275(display4: TextStyle(debugLabel: whiteMountainView display4, inherit: true, color:
I/flutter ( 4498):   Color(0xb3ffffff), family: Roboto, decoration: TextDecoration.none), display3:
I/flutter ( 4498):   TextStyle(debugLabel: whiteMountainView display3, inherit: true, color: Color(0xb3ffffff), family:
I/flutter ( 4498):   Roboto, decoration: TextDecoration.none), display2: TextStyle(debugLabel: whiteMountainView
I/flutter ( 4498):   display2, inherit: true, color: Color(0xb3ffffff), family: Roboto, decoration:
I/flutter ( 4498):   TextDecoration.none), display1: TextStyle(debugLabel: whiteMountainView display1, inherit: true,
I/flutter ( 4498):   color: Color(0xb3ffffff), family: Roboto, decoration: TextDecoration.none), headline:
I/flutter ( 4498):   TextStyle(debugLabel: whiteMountainView headline, inherit: true, color: Color(0xffffffff), family:
I/flutter ( 4498):   Roboto, decoration: TextDecoration.none), title: TextStyle(debugLabel: whiteMountainView title,
I/flutter ( 4498):   inherit: true, color: Color(0xffffffff), family: Roboto, decoration: TextDecoration.none),
I/flutter ( 4498):   subhead: TextStyle(debugLabel: whiteMountainView subhead, inherit: true, color: Color(0xffffffff),
I/flutter ( 4498):   family: Roboto, decoration: TextDecoration.none), body2: TextStyle(debugLabel: whiteMountainView
I/flutter ( 4498):   body2, inherit: true, color: Color(0xffffffff), family: Roboto, decoration: TextDecoration.none),
I/flutter ( 4498):   body1: TextStyle(debugLabel: whiteMountainView body1, inherit: true, color: Color(0xffffffff),
I/flutter ( 4498):   family: Roboto, decoration: TextDecoration.none), caption: TextStyle(debugLabel: whiteMountainView
I/flutter ( 4498):   caption, inherit: true, color: Color(0xb3ffffff), family: Roboto, decoration:
I/flutter ( 4498):   TextDecoration.none), button: TextStyle(debugLabel: whiteMountainView button, inherit: true,
I/flutter ( 4498):   color: Color(0xffffffff), family: Roboto, decoration: TextDecoration.none), subtitle):
I/flutter ( 4498):   TextStyle(debugLabel: whiteMountainView subtitle, inherit: true, color: Color(0xffffffff), family:
I/flutter ( 4498):   Roboto, decoration: TextDecoration.none), overline: TextStyle(debugLabel: whiteMountainView
I/flutter ( 4498):   overline, inherit: true, color: Color(0xffffffff), family: Roboto, decoration:
I/flutter ( 4498):   TextDecoration.none)), inputDecorationTheme: InputDecorationTheme#58914, iconTheme:
I/flutter ( 4498):   IconThemeData#2abdc(color: Color(0xdd000000)), primaryIconTheme: IconThemeData#15fa8(color:
I/flutter ( 4498):   Color(0xffffffff)), accentIconTheme: IconThemeData#15fa8(color: Color(0xffffffff)), sliderTheme:
I/flutter ( 4498):   SliderThemeData#d2834(activeTrackColor: Color(0xff5a8dd2), inactiveTrackColor: Color(0x3d5a8dd2),
I/flutter ( 4498):   inactiveTickMarkColor: Color(0x8a5a8dd2), thumbColor: Color(0xff5a8dd2), overlayColor:
I/flutter ( 4498):   Color(0x295a8dd2), valueIndicatorColor: Color(0xff5a8dd2)), tabBarTheme: TabBarTheme#12410,
I/flutter ( 4498):   chipTheme: ChipThemeData#4ec60(secondarySelectedColor: Color(0x3d5a8dd2), secondaryLabelStyle:
I/flutter ( 4498):   TextStyle(debugLabel: (blackMountainView body2).copyWith, inherit: true, color: Color(0xde5a8dd2),
I/flutter ( 4498):   family: Roboto, decoration: TextDecoration.none)), materialTapTargetSize:
I/flutter ( 4498):   MaterialTapTargetSize.padded, pageTransitionsTheme: PageTransitionsTheme#61be6, colorScheme:
I/flutter ( 4498):   ColorScheme#6dedb(primary: MaterialColor(primary value: Color(0xff2196f3)), primaryVariant:
I/flutter ( 4498):   Color(0xff1976d2), secondary: Color(0xff5a8dd2), secondaryVariant: Color(0xff1976d2), background:
I/flutter ( 4498):   Color(0xff90caf9), error: Color(0xffd32f2f), onSecondary: Color(0xffffffff), onBackground:
I/flutter ( 4498):   Color(0xffffffff))))
I/flutter ( 4498):   AnimatedTheme(duration: 200ms)
I/flutter ( 4498):   ScrollConfiguration(behavior: _MaterialScrollBehavior)
I/flutter ( 4498):   MaterialApp
I/flutter ( 4498):   App
I/flutter ( 4498):   [root]
I/flutter ( 4498): 
I/flutter ( 4498): When the exception was thrown, this was the stack:
I/flutter ( 4498): #0      debugCheckHasMaterial.<anonymous closure> (package:flutter/src/material/debug.dart:64:7)
I/flutter ( 4498): #1      debugCheckHasMaterial (package:flutter/src/material/debug.dart:67:4)
I/flutter ( 4498): #2      IconButton.build (package:flutter/src/material/icon_button.dart:197:12)
I/flutter ( 4498): #3      StatelessElement.build (package:flutter/src/widgets/framework.dart:3774:28)
I/flutter ( 4498): #4      ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3721:15)
I/flutter ( 4498): #5      Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter ( 4498): #6      ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter ( 4498): #7      ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter ( 4498): #8      Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4498): #9      Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4498): #10     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter ( 4498): #11     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter ( 4498): #12     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter ( 4498): #13     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter ( 4498): #14     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4498): #15     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4498): #16     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter ( 4498): #17     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter ( 4498): #18     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter ( 4498): #19     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter ( 4498): #20     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4498): #21     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4498): #22     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter ( 4498): #23     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter ( 4498): #24     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter ( 4498): #25     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter ( 4498): #26     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4498): #27     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4498): #28     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter ( 4498): #29     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4498): #30     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4498): #31     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter ( 4498): #32     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4498): #33     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4498): #34     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter ( 4498): #35     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter ( 4498): #36     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter ( 4498): #37     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter ( 4498): #38     ParentDataElement.mount (package:flutter/src/widgets/framework.dart:4047:11)
I/flutter ( 4498): #39     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4498): #40     MultiChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4965:32)
I/flutter ( 4498): #41     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4498): #42     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4498): #43     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter ( 4498): #44     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4498): #45     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4498): #46     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter ( 4498): #47     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter ( 4498): #48     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter ( 4498): #49     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter ( 4498): #50     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4498): #51     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4498): #52     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter ( 4498): #53     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4498): #54     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4498): #55     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter ( 4498): #56     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4498): #57     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4498): #58     SingleChildRenderObjectElement.mount (package:flutter/src/widgets/framework.dart:4860:14)
I/flutter ( 4498): #59     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4498): #60     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4498): #61     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter ( 4498): #62     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter ( 4498): #63     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter ( 4498): #64     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter ( 4498): #65     ParentDataElement.mount (package:flutter/src/widgets/framework.dart:4047:11)
I/flutter ( 4498): #66     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4498): #67     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4498): #68     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter ( 4498): #69     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter ( 4498): #70     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter ( 4498): #71     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter ( 4498): #72     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter ( 4498): #73     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4498): #74     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4498): #75     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter ( 4498): #76     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter ( 4498): #77     ComponentElement._firstBuild (package:flutter/src/widgets/framework.dart:3701:5)
I/flutter ( 4498): #78     StatefulElement._firstBuild (package:flutter/src/widgets/framework.dart:3848:11)
I/flutter ( 4498): #79     ComponentElement.mount (package:flutter/src/widgets/framework.dart:3696:5)
I/flutter ( 4498): #80     Element.inflateWidget (package:flutter/src/widgets/framework.dart:2950:14)
I/flutter ( 4498): #81     Element.updateChild (package:flutter/src/widgets/framework.dart:2753:12)
I/flutter ( 4498): #82     RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:4643:32)
I/flutter ( 4498): #83     MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:4975:17)
I/flutter ( 4498): #84     Element.updateChild (package:flutter/src/widgets/framework.dart:2742:15)
I/flutter ( 4498): #85     _TheatreElement.update (package:flutter/src/widgets/overlay.dart:507:16)
I/flutter ( 4498): #86     Element.updateChild (package:flutter/src/widgets/framework.dart:2742:15)
I/flutter ( 4498): #87     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3732:16)
I/flutter ( 4498): #88     Element.rebuild (package:flutter/src/widgets/framework.dart:3547:5)
I/flutter ( 4498): #89     BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2286:33)
I/flutter ( 4498): #90     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:676:20)
I/flutter ( 4498): #91     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:219:5)
I/flutter ( 4498): #92     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:990:15)
I/flutter ( 4498): #93     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:930:9)
I/flutter ( 4498): #94     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:842:5)
I/flutter ( 4498): #95     _invoke (dart:ui/hooks.dart:154:13)
I/flutter ( 4498): #96     _drawFrame (dart:ui/hooks.dart:143:3)
I/flutter ( 4498): ════════════════════════════════════════════════════════════════════════════════════════════════════
[✓] Flutter (Channel stable, v1.0.0, on Linux, locale en_US.UTF-8)
    • Flutter version 1.0.0 at /home/flutter/flutter_v1.0.0-stable
    • Framework revision 5391447fae (3 months ago), 2018-11-29 19:41:26 -0800
    • Engine revision 7375a0f414
    • Dart version 2.1.0 (build 2.1.0-dev.9.4 f9ebf21297)

[!] Android toolchain - develop for Android devices (Android SDK 28.0.3)
    • Android SDK at /home/android/sdk
    • Android NDK location not configured (optional; useful for native profiling support)
    • Platform android-28, build-tools 28.0.3
    • ANDROID_HOME = /home/android/sdk
    • Java binary at: /home/android/src/android-studio/jre/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)
    ! Some Android licenses not accepted.  To resolve this, run: flutter doctor --android-licenses

[✓] Android Studio (version 3.2)
    • Android Studio at /home/android/src/android-studio
    • Flutter plugin version 31.1.1
    • Dart plugin version 181.5656
    • Java version OpenJDK Runtime Environment (build 1.8.0_152-release-1136-b06)

[✓] Connected device (2 available)
    • CLT L29                   • WCR7N18511008466 • android-arm64 • Android 9 (API 28)
    • Android SDK built for x86 • emulator-5554    • android-x86   • Android 8.1.0 (API 27) (emulator)
opensourcegps commented 5 years ago

To follow up, in case IconButton added 1 sec after initState to the same place, no errors displayed.

zoechi commented 5 years ago

That's probably because you are not using MaterialApp which provides a Material widget.

If you don't want to use MaterialApp you can use

return new Scaffold(        
        appBar: new CupertinoNavigationBar(
          middle: new Text('test'),
          trailing: Material(child: IconButton(icon: Icon(Icons.settings))),      
        ),

        body: Text('test'),
);

There are several Material widgets that depend on having a Material widget as parent.

opensourcegps commented 5 years ago

I'm using MaterialApp in main.dart. There is some bug, because it blinks the error on the screen, and fixes it itself. Without MaterialApp, it would just stay in error state.

Thanks for Material(), it helps to resolve this without using delays.

zoechi commented 5 years ago

Might be my mistake that Material is still required. Glad to hear you could make it work. I assume this can be closed then.

Please consider asking support questions in one of the other channels listed at http://flutter.io/support .

opensourcegps commented 5 years ago

@zoechi this is a bug, because with Scaffold Material() should not be required. Material() just provides a workaround.

This code should not generate that error, because Scaffold already provides Material support.

return new Scaffold(        
        appBar: new CupertinoNavigationBar(
          middle: new Text('test'),
          trailing: IconButton(icon: Icon(Icons.settings)),      
        ),

        body: Text('test'),
);
zoechi commented 5 years ago

Scaffold wraps the body in a Material AppBar also wraps its content in a Material CupertinoNavigationBar does not, obviously.

opensourcegps commented 5 years ago

Then why if you put IconButton there after 1 sec, everything is fine. It would also display error, because no Material present. Anyway, not going to fight to keep it open.

zoechi commented 5 years ago

if you put IconButton there after 1 sec, everything is fine

not sure what you mean with that.

It's not about fighting. I'm happy to reopen when I think there is something that should be changed. To me it seems we should be able to find a common understanding here. This issue doesn't look too complicated 😄

cvolzke4 commented 5 years ago

I have the same problem. In my test, this works:

Future pumpWidget(WidgetTester tester, Widget widget) { return tester.pumpWidget( Material( child: MaterialApp( home: ...

But this doesn't produces the error above:

Future pumpWidget(WidgetTester tester, Widget widget) { return tester.pumpWidget( MaterialApp( home: ...

empongpat commented 5 years ago

I have the same problem, the error blink and it's gone after a few secs. Using Scaffold and AppBar as a parent.

opensourcegps commented 5 years ago

Fixed it like this:

             Material(
                  color: Colors.transparent,
                  child:_popup_menu
              ),
agallardol commented 5 years ago

I have the same problem, the error blinks. I was checking my app and I could notice that if I unwrap my widget from the Hero widget (commenting it, because my problematic widget is wrapper in a Hero) the error disappear. I think the error occur during the transition generated by the Hero widget.

opensourcegps commented 5 years ago

Blinking material error feels like a bug, but please open a new issue and possibly provide some video demo as this report is closed and will not be reviewed by flutter team.

preetamra commented 5 years ago

you should CupertinoScaffold the if you're using CupertinoNavigationBar, CupertinoScaffold provides all the Cupertino widget

MattGson commented 5 years ago

Scaffold wraps the body in a Material AppBar also wraps its content in a Material CupertinoNavigationBar does not, obviously.

This is incorrect. CupertinoNavigationBar is somehow removing any transitive material ancestor. This breaks the definition of ancestor. I have the CupertinoNavigationBar inside the Material Scaffold body but it still has the same issue.

jamesncl commented 5 years ago

I also think this is a bug and should be re-opened. I came across the same behaviour when routing from one screen to another, where both screens have Scaffolds as the root widget, and both contain the same sub-widget wrapped in a Hero. Like @agallardol, I also find the error disappears if I get rid of the Hero, so I'm pretty sure this is where the problem lies.

Here's a minimal reproducible example. You start on a screen with an edit icon. If you press the button labelled "Navigate", it will route to a second screen which has the same widget containg the icon. The icon is wrapped in a Hero. When navigating, it will throw the same error as reported in the original post, briefly show an error on the device screen, then it seems to sort itself out after a second. It complains about no Material, even though there is a Scaffold as an ancestor. If you remove the Hero, the problem goes away.

import 'package:flutter/material.dart';

void main() => runApp(MyApp());

class MyApp extends StatelessWidget {
  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Material bug',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Column(
        children: <Widget>[
          MyWidget(),
          RaisedButton(
            child: Text("Navigate"),
            onPressed: () {
              Navigator.of(context)
                  .push(MaterialPageRoute(builder: (_) => MySecondPage(),
              ));
            },
          )
        ],
      ),
    );
  }
}

class MySecondPage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: MyWidget()
    );
  }
}

class MyWidget extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Container(
      child: Hero(
        tag: "my_hero_tag",
        child: IconButton(icon: Icon(Icons.edit), onPressed: () {},),
      )
    );
  }
}
SamuelMTDavies commented 5 years ago

Having the same error even after making a minimal reproducible sample.

The official flutter docs use an InkWell widget for the onTap: function

https://flutter.dev/docs/development/ui/animations/hero-animations#standard-hero-animation-code

I was able to get the expected result by changing to a GestureDetector Widget instead. I am unsure why it would work differently and the documentation talks about using an Inkwell widget.

devmgs commented 5 years ago

I had a same issue but after changing

runApp(
        child: MaterialApp(
          title: '-----',
          debugShowCheckedModeBanner: false,
          theme: -----.theme,
          home: Splash(),
          onGenerateRoute: router.generateRoute,
        )
)

to

 runApp(new Material (
        child: MaterialApp(
          title: '----',
          debugShowCheckedModeBanner: false,
          theme: ----.theme,
          home: Splash(),
          onGenerateRoute: router.generateRoute,
        )
      )

  )

Its Working fine.

mr-muhammad-rehan commented 4 years ago

Could anyone tell me why it is not supposed to work? and throws the same error I tried this here

import 'package:flutter/material.dart';

void main() {
  runApp(MaterialApp(
    title: 'Navigation Basics',
    home: FirstRoute(),
  ));
}

class FirstRoute extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text('First Route'),
      ),
      body: Center(
        child: RaisedButton(
          child: Text('Open route'),
          onPressed: () {
            Navigator.push(
              context,
              MaterialPageRoute(builder: (context) => SecondRoute()),
            );
          },
        ),
      ),
    );
  }
}

class SecondRoute extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text("Second Route"),
      ),
      body: Center(
        child: RaisedButton(
          onPressed: () {
            showBottomSheet(
      context: context,
      builder: (context) => Container(color:Colors.red),
    );
          },
          child: Text('Go back!'),
        ),
      ),
    );
  }
}

`` ══╡ EXCEPTION CAUGHT BY GESTURE ╞═══════════════════════════════════════════════════════════════════ The following assertion was thrown while handling a gesture: No Scaffold widget found. SecondRoute widgets require a Scaffold widget ancestor. The specific widget that could not find a Scaffold ancestor was: SecondRoute The ancestors of this widget were: ... Semantics Builder RepaintBoundary-[GlobalKey#b7d7b] IgnorePointer AnimatedBuilder ... Typically, the Scaffold widget is introduced by the MaterialApp or WidgetsApp widget at the top of your application widget tree.

When the exception was thrown, this was the stack: Error: No Scaffold widget found. SecondRoute widgets require a Scaffold widget ancestor. The specific widget that could not find a Scaffold ancestor was: SecondRoute The ancestors of this widget were: Semantics Builder RepaintBoundary-[GlobalKey#b7d7b] IgnorePointer AnimatedBuilder FadeTransition FractionalTranslation SlideTransition _FadeUpwardsPageTransition AnimatedBuilder RepaintBoundary _FocusMarker Semantics FocusScope PageStorage Offstage _ModalScopeStatus _ModalScope-[LabeledGlobalKey<_ModalScopeState>#a9424] _OverlayEntry-[LabeledGlobalKey<_OverlayEntryState>#dfc02] Stack _Theatre Overlay-[LabeledGlobalKey#6c68a] _FocusMarker Semantics FocusScope AbsorbPointer _PointerListener Listener Navigator-[GlobalObjectKey _WidgetsAppState#8dd0f] IconTheme IconTheme _InheritedCupertinoTheme CupertinoTheme _InheritedTheme Theme AnimatedTheme Builder DefaultTextStyle CustomPaint Banner CheckedModeBanner Title Directionality _LocalizationsScope-[GlobalKey#3fc24] Semantics Localizations MediaQuery _MediaQueryFromWindow DefaultFocusTraversal Actions _ShortcutsMarker Semantics _FocusMarker Focus Shortcuts WidgetsApp-[GlobalObjectKey MaterialAppState#ce4ab] ScrollConfiguration MaterialApp [root] Typically, the Scaffold widget is introduced by the MaterialApp or WidgetsApp widget at the top of your application widget tree. at Object.throw [as throw] ([Dart SDK Source]:4004:11) at [Flutter SDK Source]:140054:19 at Object.debugCheckHasScaffold ([Flutter SDK Source]:140065:21) at Object.showBottomSheet ([Flutter SDK Source]:126967:26) at ink_well.InkWell.new. (:98:28) at _InkResponseState.new.[_handleTap] ([Flutter SDK Source]:151789:23) at [Flutter SDK Source]:151865:642 at tap$.TapGestureRecognizer.new.invokeCallback ([Flutter SDK Source]:232339:18) at tap$.TapGestureRecognizer.new.handleTapUp ([Flutter SDK Source]:251048:40) at tap$.TapGestureRecognizer.new.[_checkUp] ([Flutter SDK Source]:232691:12) at tap$.TapGestureRecognizer.new.handlePrimaryPointer ([Flutter SDK Source]:232641:23) at tap$.TapGestureRecognizer.new.handleEvent ([Flutter SDK Source]:232540:16) at pointer_router.PointerRouter.new.[_dispatch] ([Flutter SDK Source]:260992:9) at [Flutter SDK Source]:261012:27 at LinkedMap.new.forEach ([Dart SDK Source]:29751:11) at pointer_router.PointerRouter.new.[_dispatchEventToRoutes] ([Flutter SDK Source]:261010:29) at pointer_router.PointerRouter.new.route ([Flutter SDK Source]:261005:37) at binding$.WidgetsFlutterBinding.new.handleEvent ([Flutter SDK Source]:214420:26) at binding$.WidgetsFlutterBinding.new.dispatchEvent ([Flutter SDK Source]:214408:24) at binding$.WidgetsFlutterBinding.new.[_handlePointerEvent] ([Flutter SDK Source]:214385:14) at binding$.WidgetsFlutterBinding.new.[_flushPointerEventQueue] ([Flutter SDK Source]:214359:35) at binding$.WidgetsFlutterBinding.new.[_handlePointerDataPacket] ([Flutter SDK Source]:214350:65) at _engine.PointerBinding.new.[_onPointerData] ([Dart SDK Source]:145345:9) at [Dart SDK Source]:145559:26 at HTMLElement. ([Dart SDK Source]:145494:11)

Handler: "onTap" Recognizer: TapGestureRecognizer#6fb4a ════════════════════════════════════════════════════════════════════════════════════════════════════ ``

asimansar commented 4 years ago

I had a same issue but after changing

runApp(
        child: MaterialApp(
          title: '-----',
          debugShowCheckedModeBanner: false,
          theme: -----.theme,
          home: Splash(),
          onGenerateRoute: router.generateRoute,
        )
)

to

 runApp(new Material (
        child: MaterialApp(
          title: '----',
          debugShowCheckedModeBanner: false,
          theme: ----.theme,
          home: Splash(),
          onGenerateRoute: router.generateRoute,
        )
      )

  )

Its Working fine.

"This is the absoloute solution for the problem . Thank you very much bro"

github-actions[bot] commented 3 years ago

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.