Skip to content

[go_router] Hero animation don't work between pages nested on ShellRoute #112095

@tonyrbf96

Description

@tonyrbf96

Steps to Reproduce

  1. Execute flutter run on the code sample
  2. Tap on the Flutter logo to go to details page.

Expected results:

expect.MP4

Actual results:

results.MP4
Code sample
import 'package:flutter/material.dart';
import 'package:go_router/go_router.dart';

final router = GoRouter(
  initialLocation: '/a',
  routes: [
    ShellRoute(
      builder: (context, state, child) => child,
      routes: [
        GoRoute(
          path: '/a',
          builder: (context, state) => const PageA(),
          routes: [
            GoRoute(
              path: 'details',
              builder: (context, state) => const PageADetails(),
            )
          ],
        ),
      ],
    )
  ],
);

void main{
  runApp(
      MaterialApp.router(
        routeInformationParser: router.routeInformationParser,
        routeInformationProvider: router.routeInformationProvider,
        routerDelegate: router.routerDelegate,
      ),
   );
}


class PageA extends StatelessWidget {
  const PageA({super.key});

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: GestureDetector(
          onTap: () {
            context.go('/a/details');
          },
          child: const Hero(
            tag: 'tag',
            child: SizedBox.square(
              dimension: 100,
              child: FlutterLogo(),
            ),
          ),
        ),
      ),
    );
  }
}

class PageADetails extends StatelessWidget {
  const PageADetails({super.key});

  @override
  Widget build(BuildContext context) {
    return const Scaffold(
      body: Center(
        child: Hero(
          tag: 'tag',
          child: SizedBox.square(
            dimension: 200,
            child: FlutterLogo(),
          ),
        ),
      ),
    );
  }
}
Logs
[No exception or error logs]
Analyzing app...                                                        
No issues found! (ran in 8.7s)
[✓] Flutter (Channel stable, 3.3.0, on macOS 12.5 21G72 darwin-x64, locale en-US)
    • Flutter version 3.3.0 on channel stable at /Users/tony/flutter
    • Upstream repository https://github.com/flutter/flutter.git
    • Framework revision ffccd96b62 (3 weeks ago), 2022-08-29 17:28:57 -0700
    • Engine revision 5e9e0e0aa8
    • Dart version 2.18.0
    • DevTools version 2.15.0

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.1)
    • Android SDK at /Users/tony/Library/Android/sdk
    • Platform android-31, build-tools 30.0.1
    • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)
    • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 13.4.1)
    • Xcode at /Applications/Xcode.app/Contents/Developer
    • Build 13F100
    • CocoaPods version 1.11.2

[✓] Chrome - develop for the web
    • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1)
    • Android Studio at /Applications/Android Studio.app/Contents
    • Flutter plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/9212-flutter
    • Dart plugin can be installed from:
      🔨 https://plugins.jetbrains.com/plugin/6351-dart
    • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[✓] VS Code (version 1.71.1)
    • VS Code at /Applications/Visual Studio Code.app/Contents
    • Flutter extension version 3.46.0

[✓] Connected device (3 available)
    • Tony Xr (mobile) • 00008020-000C11A23C02003A • ios            • iOS 15.4.1 19E258
    • macOS (desktop)  • macos                     • darwin-x64     • macOS 12.5 21G72 darwin-x64
    • Chrome (web)     • chrome                    • web-javascript • Google Chrome 97.0.4692.71

[✓] HTTP Host Availability
    • All required HTTP hosts are available

• No issues found!

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2Important issues not at the top of the work listfound in release: 3.3Found to occur in 3.3found in release: 3.4Found to occur in 3.4has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: go_routerThe go_router packagepackageflutter/packages repository. See also p: labels.r: fixedIssue is closed as already fixed in a newer version

    Type

    No type

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions