Search packages, repositories and app categories

Package detailsv0.4.8

swipeable_page_route

Swipe to navigate back and admire beautifully morphing widgets

AndroidiOSmacOSWindowsLinux
30-day downloads
14.2K
Likes
320
Pub points
160

Install package

flutter pub add swipeable_page_route

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

SwipeablePageRoute is a Flutter package that enables intuitive swipe-to-navigate-back gestures on pages, enhancing user experience with smooth, morphing transitions between screens. It extends the standard PageRoute, offering customizable animations and seamless integration into existing navigation flows. Ideal for apps prioritizing fluid, interactive navigation, it supports multiple platforms including Android, iOS, macOS, Windows, and Linux. The package is lightweight and designed to work effortlessly with Flutter's routing system.

Use cases

  • Implementing swipe-back navigation in mobile apps
  • Creating immersive user experiences with animated transitions
  • Enhancing app interactivity with gesture-driven navigation
  • Building consistent navigation patterns across platforms
  • Adding visual polish to screen transitions

Key features

  • Smooth swipe-to-back gesture support
  • Customizable transition animations
  • Cross-platform compatibility
  • Easy integration with existing routes
  • Morphing widget transitions during navigation

Suitable for

  • Developers seeking gesture-based navigation
  • Apps focused on user engagement and UX
  • Flutter projects targeting multiple platforms
  • Design-conscious applications with rich animations
  • Teams wanting minimal setup for advanced navigation

Considerations

  • May require additional styling for complex transitions
  • Performance impact with heavy widgets during animation
  • Limited customization beyond basic swipe behavior
  • Not ideal for simple, static navigation flows
  • Requires careful handling in nested navigation scenarios

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

🔙 Swipe to navigate back and admire beautifully morphing widgets.

swipeable_page_route demo

SwipeablePageRoute

SwipeablePageRoute is a specialized CupertinoPageRoute that allows your users to go back by swiping anywhere on the current page. Use it instead of MaterialPageRoute or CupertinoPageRoute:

Navigator.of(context).push(SwipeablePageRoute(
  builder: (BuildContext context) => MyPageContent(),
));

If your page contains horizontally scrollable content, you can limit SwipeablePageRoute to only react on drags from the start (left in LTR, right in RTL) screen edge — just like CupertinoPageRoute:

Navigator.of(context).push(SwipeablePageRoute(
  canOnlySwipeFromEdge: true,
  builder: (BuildContext context) => MyHorizontallyScrollablePageContent(),
));

You can get the SwipeablePageRoute wrapping your current page using context.getSwipeablePageRoute<T>().

To use swipeable pages with a PageTransitionsTheme, use SwipeablePageTransitionsBuilder.

⚠️ SwipeablePageTransitionsBuilder must be set for TargetPlatform.iOS. For all other platforms, you can decide whether you want to use it. This is because PageTransitionsTheme uses the builder for iOS whenever a pop gesture is in progress.

Usage with Go Router

To use swipeable pages with Flutter's Go Router, use SwipeablePage and the pageBuilder parameter in GoRoute instead of builder:

// Before, without swipeable pages:
GoRoute(
  builder: (context, state) => const MyScreen(),
  // ...
)

// After, with swipeable pages:
GoRoute(
  pageBuilder: (context, state) => SwipeablePage(
    builder: (context) => MyScreen(),
  ),
  // ...
)

MorphingAppBar & MorphingSliverAppBar

As you can see in the demo above, there's a beautiful animation happening to the app bar. That's a MorphingAppBar!

You can construct MorphingAppBar (corresponds to AppBar) and MorphingSliverAppBar (corresponds to SliverAppBar) just like the originals:

MorphingAppBar(
  backgroundColor: Colors.green,
  title: Text('My Page'),
  actions: [
    IconButton(
      key: ValueKey('play'),
      icon: Icon(Icons.play_arrow),
      onPressed: () {},
    ),
    IconButton(
      key: ValueKey('favorite'),
      icon: Icon(Icons.favorite),
      onPressed: () {},
    ),
    PopupMenuButton<void>(
      key: ValueKey('overflow'),
      itemBuilder: (context) => [
        PopupMenuItem<void>(child: Text('Overflow action 1')),
        PopupMenuItem<void>(child: Text('Overflow action 2')),
      ],
    ),
  ],
  bottom: TabBar(tabs: [
    Tab(text: 'Tab 1'),
    Tab(text: 'Tab 2'),
    Tab(text: 'Tab 3'),
  ]),
)

Both MorphingAppBars internally use Heros, so if you're not navigating directly inside a MaterialApp, you have to add a HeroController to your Navigator:

Navigator(
  observers: [HeroController()],
  onGenerateRoute: // ...
)

To animate additions, removals, and constants in your AppBars actions, we compare them using Widget.canUpdate(Widget old, Widget new). It compares Widgets based on their type and key, so it's recommended to give every action Widget a key (that you reuse across pages) for correct animations.

Categories

Dependencies

Dependency list 3 items

Source repository

Projects using this package

No data available yet.