Skip to content

Visibility not restored for Hero after pop #40239

Description

@hahafather007

After clicking the Hero widget to jump to a list page, scroll down the list until the Hero widget of the corresponding tag leaves the screen and then return to the page. The Hero widget of the previous page will be blank. This is a very serious problem, and now our online project has been plagued by this problem.
QQ20190911-173956@2x
QQ20190911-174016@2x
Flutter version:

[✓] Flutter (Channel beta, v1.7.8+hotfix.4-pre.7, on Mac OS X 10.14.6 18G87,
    locale zh-Hans-CN)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 10.3)
[✓] Android Studio (version 3.5)
[!] IntelliJ IDEA Community Edition (version 2019.2.1)
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
[✓] Connected device (1 available)

Reproduce code like this:

import 'package:flutter/material.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(),
      body: Center(
        child: GestureDetector(
          onTap: () {
            Navigator.of(context).push(MaterialPageRoute(builder: (context) {
              return Scaffold(
                body: ListView(
                  children: <Widget>[
                    Center(
                      child: Hero(
                        tag: "111",
                        child: Container(
                          width: 50,
                          height: 50,
                          color: Colors.blue,
                        ),
                      ),
                    ),
                    Container(
                      height: 2000,
                    ),
                  ],
                ),
              );
            }));
          },
          child: Hero(
            tag: "111",
            child: Container(
              width: 50,
              height: 50,
              color: Colors.blue,
            ),
          ),
        ),
      ),
    );
  }
}

Metadata

Metadata

Labels

a: animationAnimation APIsc: regressionIt was better in the past than it is nowf: routesNavigator, Router, and related APIs.frameworkflutter/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