An animation library for sliding right back to the previous route

Features

Demo

Getting started

dependencies:
    horizontal_drag_back_widget: ^lastest

Usage

1.add navigatorObservers

navigatorObservers: [
  HorizontalRouteObserver.getInstance(),
],

2.First Page add HorizontalDragBackParentWidget

HorizontalDragBackParentWidget(
    child: ...
),

3.Second page add HorizontalDragBackContainer

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

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      backgroundColor: Colors.transparent,
      body: HorizontalDragBackContainer(
        child: Builder(
            builder: (context) {
              return Container(
                width: double.infinity,
                color: Colors.white,
                child: Column(
                  mainAxisAlignment: MainAxisAlignment.center,
                  children: [
                    const Text('Second Page'),
                    MaterialButton(
                      onPressed: () {
                        HorizontalDragBackState.of(context)?.pop();
                      },
                      child: const Text("BACK"),
                    )
                  ],
                ),
              );
            }
        ),
      ),
    );
  }
}

Additional information

child page settings

opaque: false

pop animation method

HorizontalDragBackState.of(context)?.pop();