Skip to content

Table widget doesn't work with Hero animations. #31473

@tvolkert

Description

@tvolkert

Steps to reproduce

Run the following app, and tap on the text.

import 'package:flutter/material.dart';

void main() => runApp(MaterialApp(home: Home()));

class Home extends StatelessWidget {
  const Home({
    Key key,
  }) : super(key: key);

  void startHeroTransition(BuildContext context) {
    Navigator.of(context).push(MaterialPageRoute(
      builder: (BuildContext context) => Center(child: HeroText()),
    ));
  }

  @override
  Widget build(BuildContext context) {
    return SafeArea(
      child: GestureDetector(
        onTap: () => startHeroTransition(context),
        child: Table(
          children: [
            TableRow(
              children: [
                HeroText(),
              ],
            ),
          ],
        ),
      ),
    );
  }
}

class HeroText extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Hero(
      tag: 'TAG',
      child: Material(child: Text('Tap here to reproduce the bug')),
    );
  }
}

Expected behavior

The text should animate via a hero transition to the center of the screen, with no exceptions in the logs.

Actual behavior

I/flutter (23398): ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (23398): The following assertion was thrown building Hero(tag: TAG, state: _HeroState#f6027):
I/flutter (23398): 'package:flutter/src/widgets/table.dart': Failed assertion: line 286 pos 12: '() {
I/flutter (23398):       if (_debugWillReattachChildren)
I/flutter (23398):         return true;
I/flutter (23398):       for (Element forgottenChild in _forgottenChildren) {
I/flutter (23398):         if (forgottenChild.renderObject == child)
I/flutter (23398):           return true;
I/flutter (23398):       }
I/flutter (23398):       return false;
I/flutter (23398):     }()': is not true.
I/flutter (23398): 
I/flutter (23398): Either the assertion indicates an error in the framework itself, or we should provide substantially
I/flutter (23398): more information in this error message to help you determine and fix the underlying cause.
I/flutter (23398): In either case, please report this assertion by filing a bug on GitHub:
I/flutter (23398):   https://github.com/flutter/flutter/issues/new?template=BUG.md
I/flutter (23398): 
I/flutter (23398): When the exception was thrown, this was the stack:
I/flutter (23398): #2      _TableElement.removeChildRenderObject (package:flutter/src/widgets/table.dart:286:12)
I/flutter (23398): #3      RenderObjectElement.detachRenderObject (package:flutter/src/widgets/framework.dart:4744:36)
I/flutter (23398): #4      Element.detachRenderObject.<anonymous closure> (package:flutter/src/widgets/framework.dart:2867:13)
I/flutter (23398): #5      ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3770:14)
I/flutter (23398): #6      Element.detachRenderObject (package:flutter/src/widgets/framework.dart:2866:5)
I/flutter (23398): #7      Element.detachRenderObject.<anonymous closure> (package:flutter/src/widgets/framework.dart:2867:13)
I/flutter (23398): #8      ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3770:14)
I/flutter (23398): #9      Element.detachRenderObject (package:flutter/src/widgets/framework.dart:2866:5)
I/flutter (23398): #10     Element.detachRenderObject.<anonymous closure> (package:flutter/src/widgets/framework.dart:2867:13)
I/flutter (23398): #11     ComponentElement.visitChildren (package:flutter/src/widgets/framework.dart:3770:14)
I/flutter (23398): #12     Element.detachRenderObject (package:flutter/src/widgets/framework.dart:2866:5)
I/flutter (23398): #13     Element.deactivateChild (package:flutter/src/widgets/framework.dart:2996:11)
I/flutter (23398): #14     Element.updateChild (package:flutter/src/widgets/framework.dart:2761:7)
I/flutter (23398): #15     ComponentElement.performRebuild (package:flutter/src/widgets/framework.dart:3750:16)
I/flutter (23398): #16     Element.rebuild (package:flutter/src/widgets/framework.dart:3565:5)
I/flutter (23398): #17     BuildOwner.buildScope (package:flutter/src/widgets/framework.dart:2278:33)
I/flutter (23398): #18     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding&WidgetsBinding.drawFrame (package:flutter/src/widgets/binding.dart:700:20)
I/flutter (23398): #19     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding&PaintingBinding&SemanticsBinding&RendererBinding._handlePersistentFrameCallback (package:flutter/src/rendering/binding.dart:286:5)
I/flutter (23398): #20     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._invokeFrameCallback (package:flutter/src/scheduler/binding.dart:1012:15)
I/flutter (23398): #21     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding.handleDrawFrame (package:flutter/src/scheduler/binding.dart:952:9)
I/flutter (23398): #22     _WidgetsFlutterBinding&BindingBase&GestureBinding&ServicesBinding&SchedulerBinding._handleDrawFrame (package:flutter/src/scheduler/binding.dart:864:5)
I/flutter (23398): #26     _invoke (dart:ui/hooks.dart:219:10)
I/flutter (23398): #27     _drawFrame (dart:ui/hooks.dart:178:3)
I/flutter (23398): (elided 5 frames from class _AssertionError and package dart:async)
I/flutter (23398): ════════════════════════════════════════════════════════════════════════════════════════════════════

Metadata

Metadata

Labels

c: crashStack traces logged to the consoleframeworkflutter/packages/flutter repository. See also f: labels.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions