-
Notifications
You must be signed in to change notification settings - Fork 27.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Assertion hit when navigating to a Scaffold with different body Widget #4617
Comments
cc @Hixie |
import 'dart:math';
import 'package:flutter/material.dart';
class Home extends StatelessWidget {
static final GlobalKey<ScaffoldState> _scaffoldKey = new GlobalKey<ScaffoldState>();
Home({ Key key, this.grid: false }) : super(key: key);
final bool grid;
@override
Widget build(BuildContext context) {
return new Scaffold(
key: _scaffoldKey,
body: new CustomScrollView(
slivers: <Widget>[
new SliverAppBar(
actions: <Widget>[
new IconButton(
icon: new Icon(Icons.bug_report),
onPressed: () => _toggleGrid(context, !grid)
)
]
),
_buildBody(context),
]
)
);
}
Widget _buildBody(BuildContext context) {
if (grid) {
return new SliverGrid(
gridDelegate: new SliverGridDelegateWithMaxCrossAxisExtent(maxCrossAxisExtent: 500.0),
delegate: new SliverChildListDelegate(<Widget>[])
);
}
else {
return new SliverList(delegate: new SliverChildListDelegate(<Widget>[new SizedBox()]));
}
}
void _toggleGrid(BuildContext context, bool grid) {
Navigator.push(context, new MaterialPageRoute<Null>(
builder: (BuildContext context) {
return new Home(grid: grid);
}
));
}
}
void main() {
runApp(new MaterialApp(home: new Home()));
} |
Doesn't throw an exception anymore. It's still banana pants crazy code. The global key is static and used in both routes. That's not really legal because they're both on screen at the same time during the transition... In any case, the assert is fixed in the new world. |
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 |
Assertion text at the end. Try running the following test case. Tap the bug icon in the top right, then navigate back. The assert will trigger.
--- test case ---
--- assertion ---
I/flutter : ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter : The following assertion was thrown building Home:
I/flutter : scheduleBuildFor() called for a widget for which a build was already scheduled.
I/flutter : The method was called for the following element:
I/flutter : Scaffold([GlobalKey 189767604]; dirty; state: ScaffoldState(415291577))
I/flutter : The current dirty list consists of:
I/flutter : [Navigator([GlobalObjectKey _WidgetsAppState(859688735)]; state: NavigatorState(920361667)),
I/flutter : Overlay([GlobalKey 633196994]; state: OverlayState(150832888; entries:
I/flutter : [OverlayEntry@1021495924(opaque: false), OverlayEntry@819921818(opaque: false),
I/flutter : OverlayEntry@651833355(opaque: false), OverlayEntry@107573855(opaque: false)])),
I/flutter : _ModalScope([GlobalKey 558734001]; state: _ModalScopeState(768887326)),
I/flutter : _MaterialPageTransition(animation: AnimationController(◀ 1.000; for
I/flutter : MaterialPageRoute(null))➩Cubic(0.00, 0.00, 0.58, 1.00); state: _AnimatedState(551097036)),
I/flutter : Scaffold([GlobalKey 189767604]; dirty; state: ScaffoldState(415291577)),
I/flutter : Material(MaterialType.canvas; elevation: 0; state: _MaterialState(659163102)),
I/flutter : AnimatedContainer(duration: 200ms; has background; state: _AnimatedContainerState(112921519; has
I/flutter : background)), DecoratedBox(renderObject: RenderDecoratedBox DETACHED), DecoratedBox(renderObject:
I/flutter : RenderDecoratedBox DETACHED), AnimatedDefaultTextStyle(duration: 200ms; inherit: false; color:
I/flutter : Color(0xdd000000); family: "Roboto"; size: 14.0; weight: 400; baseline: alphabetic; state:
I/flutter : _AnimatedDefaultTextStyleState(812479847)), ScrollableGrid(dirty), OverscrollIndicator(dirty;
I/flutter : state: _OverscrollIndicatorState(549925713)), AnimatedBuilder(animation: AnimationController(⏮
I/flutter : 0.000; paused); dirty; state: _AnimatedState(172612090)), Scrollable(dirty; state:
I/flutter : ScrollableState(275226834)), RawGestureDetector([GlobalKey 679576939]; dirty; state:
I/flutter : RawGestureDetectorState(531534497; gestures: ; behavior: opaque)),
I/flutter : LayoutBuilder(renderObject: _RenderLayoutBuilder NEEDS-LAYOUT DETACHED),
I/flutter : Material(MaterialType.canvas; elevation: 4; color: Color(0xff2196f3); dirty; state:
I/flutter : _MaterialState(667497626)), AnimatedContainer(duration: 200ms; has background; dirty; state:
I/flutter : _AnimatedContainerState(354192772; has background)), DecoratedBox(dirty; renderObject:
I/flutter : RenderDecoratedBox DETACHED), DecoratedBox(dirty; renderObject: RenderDecoratedBox DETACHED),
I/flutter : AnimatedDefaultTextStyle(duration: 200ms; inherit: false; color: Color(0xdd000000); family:
I/flutter : "Roboto"; size: 14.0; weight: 400; baseline: alphabetic; dirty; state:
I/flutter : _AnimatedDefaultTextStyleState(714683845)), InkResponse(dirty; state:
I/flutter : _InkResponseState(992907223)), RawGestureDetector(dirty; state:
I/flutter : RawGestureDetectorState(769897258; gestures: tap; behavior: opaque)), Icon(IconData(U+0E868);
I/flutter : size: 24.0; dirty), Text(""; inherit: false; color: Color(0xffffffff); family: "MaterialIcons";
I/flutter : size: 24.0; dirty), _FloatingActionButtonTransition(state:
I/flutter : _FloatingActionButtonTransitionState(299703103)), ScaleTransition(animation: AnimationController(⏭
I/flutter : 1.000; paused)➩Cubic(0.42, 0.00, 1.00, 1.00); state: _AnimatedState(547328635)),
I/flutter : RotationTransition(animation: AnimationController(⏭ 1.000; paused)➩Cubic(0.42, 0.00, 1.00,
I/flutter : 1.00)➩Tween(-0.125 → 0.0)➩0.0; state: _AnimatedState(1049967363))]
I/flutter : This should not be possible and probably indicates a bug in the widgets framework. Please report it:
I/flutter : https://github.com/flutter/flutter/issues/new
I/flutter : When the exception was thrown, this was the stack:
I/flutter : #0 BuildOwner.scheduleBuildFor. (package:flutter/src/widgets/framework.dart:738)
I/flutter : #1 _AssertionError._checkAssertion (dart:core-patch/errors_patch.dart:31)
I/flutter : #2 BuildOwner.scheduleBuildFor (package:flutter/src/widgets/framework.dart:736)
I/flutter : #3 BuildableElement.markNeedsBuild (package:flutter/src/widgets/framework.dart:1451)
I/flutter : #4 BuildableElement.activate (package:flutter/src/widgets/framework.dart:1510)
I/flutter : #5 StatefulElement.activate (package:flutter/src/widgets/framework.dart:1697)
I/flutter : #6 Element._activateRecursively (package:flutter/src/widgets/framework.dart:1163)
I/flutter : #7 Element._activateWithParent (package:flutter/src/widgets/framework.dart:1156)
I/flutter : #8 Element.inflateWidget (package:flutter/src/widgets/framework.dart:1119)
I/flutter : #9 Element.updateChild (package:flutter/src/widgets/framework.dart:1004)
I/flutter : #10 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:1582)
I/flutter : #11 BuildableElement.rebuild (package:flutter/src/widgets/framework.dart:1484)
I/flutter : #12 StatelessElement.update (package:flutter/src/widgets/framework.dart:1621)
I/flutter : #13 Element.updateChild (package:flutter/src/widgets/framework.dart:997)
I/flutter : #14 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:1582)
I/flutter : #15 BuildableElement.rebuild (package:flutter/src/widgets/framework.dart:1484)
I/flutter : #16 _ProxyElement.update (package:flutter/src/widgets/framework.dart:1768)
I/flutter : #17 Element.updateChild (package:flutter/src/widgets/framework.dart:997)
I/flutter : #18 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:1582)
I/flutter : #19 BuildableElement.rebuild (package:flutter/src/widgets/framework.dart:1484)
I/flutter : #20 StatelessElement.update (package:flutter/src/widgets/framework.dart:1621)
I/flutter : #21 Element.updateChild (package:flutter/src/widgets/framework.dart:997)
I/flutter : #22 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:2239)
I/flutter : #23 Element.updateChild (package:flutter/src/widgets/framework.dart:997)
I/flutter : #24 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:2239)
I/flutter : #25 Element.updateChild (package:flutter/src/widgets/framework.dart:997)
I/flutter : #26 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:1582)
I/flutter : #27 BuildableElement.rebuild (package:flutter/src/widgets/framework.dart:1484)
I/flutter : #28 StatefulElement.update (package:flutter/src/widgets/framework.dart:1692)
I/flutter : #29 Element.updateChild (package:flutter/src/widgets/framework.dart:997)
I/flutter : #30 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:2239)
I/flutter : #31 Element.updateChild (package:flutter/src/widgets/framework.dart:997)
I/flutter : #32 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:2239)
I/flutter : #33 Element.updateChild (package:flutter/src/widgets/framework.dart:997)
I/flutter : #34 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:1582)
I/flutter : #35 BuildableElement.rebuild (package:flutter/src/widgets/framework.dart:1484)
I/flutter : #36 _ProxyElement.update (package:flutter/src/widgets/framework.dart:1768)
I/flutter : #37 Element.updateChild (package:flutter/src/widgets/framework.dart:997)
I/flutter : #38 SingleChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:2239)
I/flutter : #39 Element.updateChild (package:flutter/src/widgets/framework.dart:997)
I/flutter : #40 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:1582)
I/flutter : #41 BuildableElement.rebuild (package:flutter/src/widgets/framework.dart:1484)
I/flutter : #42 StatefulElement.update (package:flutter/src/widgets/framework.dart:1692)
I/flutter : #43 Element.updateChild (package:flutter/src/widgets/framework.dart:997)
I/flutter : #44 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:1582)
I/flutter : #45 BuildableElement.rebuild (package:flutter/src/widgets/framework.dart:1484)
I/flutter : #46 StatefulElement.update (package:flutter/src/widgets/framework.dart:1692)
I/flutter : #47 Element.updateChild (package:flutter/src/widgets/framework.dart:997)
I/flutter : #48 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:1582)
I/flutter : #49 BuildableElement.rebuild (package:flutter/src/widgets/framework.dart:1484)
I/flutter : #50 StatefulElement.update (package:flutter/src/widgets/framework.dart:1692)
I/flutter : #51 Element.updateChild (package:flutter/src/widgets/framework.dart:997)
I/flutter : #52 RenderObjectElement.updateChildren (package:flutter/src/widgets/framework.dart:2084)
I/flutter : #53 MultiChildRenderObjectElement.update (package:flutter/src/widgets/framework.dart:2332)
I/flutter : #54 Element.updateChild (package:flutter/src/widgets/framework.dart:997)
I/flutter : #55 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:1582)
I/flutter : #56 BuildableElement.rebuild (package:flutter/src/widgets/framework.dart:1484)
I/flutter : #57 StatefulElement.update (package:flutter/src/widgets/framework.dart:1692)
I/flutter : #58 Element.updateChild (package:flutter/src/widgets/framework.dart:997)
I/flutter : #59 ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:1582)
I/flutter : #60 BuildableElement.rebuild (package:flutter/src/widgets/framework.dart:1484)
I/flutter : #61 BuildOwner.buildDirtyElements. (package:flutter/src/widgets/framework.dart:834)
I/flutter : #62 BuildOwner.lockState (package:flutter/src/widgets/framework.dart:794)
I/flutter : #63 BuildOwner.buildDirtyElements (package:flutter/src/widgets/framework.dart:829)
I/flutter : #64 BindingBase&SchedulerBinding&GestureBinding&ServicesBinding&RendererBinding&WidgetsBinding.beginFrame (package:flutter/src/widgets/binding.dart:203)
I/flutter : #65 BindingBase&SchedulerBinding&GestureBinding&ServicesBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:144)
I/flutter : #66 BindingBase&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:428)
I/flutter : #67 BindingBase&SchedulerBinding.handleBeginFrame (package:flutter/src/scheduler/binding.dart:388)
I/flutter : #68 _beginFrame (file:///b/build/slave/Linux_Engine/build/src/out/android_debug/gen/sky/bindings/dart_ui/hooks.dart:48)
I/flutter : ════════════════════════════════════════════════════════════════════════════════════════════════════
I/flutter : Another exception was thrown: 'package:flutter/src/widgets/framework.dart': Failed assertion: line 1037: '_debugLifecycleState == _ElementLifecycle.active' is not true.
I/flutter : dispose scrollable
Application finished.
The text was updated successfully, but these errors were encountered: