Skip to content

Trying out go_router support for OpenContainer#11611

Draft
Piinks wants to merge 1 commit intoflutter:mainfrom
Piinks:animations_go_router
Draft

Trying out go_router support for OpenContainer#11611
Piinks wants to merge 1 commit intoflutter:mainfrom
Piinks:animations_go_router

Conversation

@Piinks
Copy link
Copy Markdown
Contributor

@Piinks Piinks commented Apr 29, 2026

Design Doc

This PR fixes flutter/flutter#121929 by making the OpenContainer widget compatible with declarative routers like go_router.

Problem

OpenContainer previously hardcoded an imperative Navigator.push call. When used with declarative routers on the web, this prevented the browser URL from updating when the container opened. Manually triggering a router navigation would lose the signature "morphing" animation because the destination page had no metadata about the source widget's position/size.

Solution

I have introduced a coordination mechanism that allows the source widget and the destination page to share animation metadata while letting the Router own the navigation state.

Key Changes

  1. A new Page class that can be used in Router route definitions.
  2. Added to OpenContainer to allow overriding the default imperative push with a declarative navigation call (e.g., context.go()).
  3. A shared identifier (similar to Hero.tag) used to link the source OpenContainer with the destination OpenContainerPage.
  4. An internal registry that coordinates the "morphing" measurements between the source and destination.
  5. Updated OpenContainerRoute to handle cases where the source widget is not present (e.g., direct URL deep-linking) by falling back to a smooth fade transition.
  6. Made OpenContainerRoute and Hideable public to support these new declarative workflows.

Usage Example

// List Page
OpenContainer(
  transitionTag: 'item-$id',
  onOpen: () => context.go('/details/$id'),
  closedBuilder: (context, action) => ListTile(onTap: action, ...),
  openBuilder: (context, action) => DetailsPage(id: id),
)

// Router Config
GoRoute(
  path: '/details/:id',
  pageBuilder: (context, state) => OpenContainerPage(
    transitionTag: 'item-${state.pathParameters['id']}',
    openBuilder: (context, action) => DetailsPage(id: id),
  ),
)

Pre-Review Checklist

If you need help, consider asking for advice on the #hackers-new channel on Discord.

Note: The Flutter team is currently trialing the use of Gemini Code Assist for GitHub. Comments from the gemini-code-assist bot should not be taken as authoritative feedback from the Flutter team. If you find its comments useful you can update your code accordingly, but if you are unsure or disagree with the feedback, please feel free to wait for a Flutter team member's review for guidance on which automated comments should be addressed.

Footnotes

  1. Regular contributors who have demonstrated familiarity with the repository guidelines only need to comment if the PR is not auto-exempted by repo tooling. 2

@flutter-dashboard flutter-dashboard Bot added the CICD Run CI/CD label Apr 29, 2026
@github-actions github-actions Bot added p: animations triage-framework Should be looked at in framework triage labels Apr 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CICD Run CI/CD p: animations triage-framework Should be looked at in framework triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[animation] using animations package with go_router package instead of Navigator.push() method

1 participant