Keeping the system's PopScope widget, is simpler and more efficient.

Features

✅ You can use PopScope widget;

✅ Support for multiple platforms;

✅ It is the same as the default sideslip back. Takes effect only when a pop is triggered, otherwise it is cancelled;

demo.gif

Usage

To use this package, add pop_scope_page_transitions as a dependency in your pubspec.yaml file.

example.

Example

Import the library

import 'package:pop_scope_page_transitions/pop_scope_page_transitions.dart';

Configure page transitions


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

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        colorScheme: ColorScheme.fromSeed(seedColor: Colors.deepPurple),
        useMaterial3: true,
        pageTransitionsTheme: const PageTransitionsTheme(
          builders: {
            // TargetPlatform.android: PopScopePageTransitionsBuilder(),
            TargetPlatform.iOS: PopScopePageTransitionsBuilder(),
          },
        ),
      ),
      routes: {
        '/': (context) => const HomePage(),
        '/second': (context) => const SecondPage(),
      },
    );
  }
}

And then, you can add PopScope widget in your view.