Route Detector

Route Detector is a flutter library for easily observing the navigation route


1- Add the latest version of package to your pubspec.yaml.

 route_detector: - latest version -

2- Import the package and use it in your Flutter App.

import 'package:route_detector/route_detector.dart';


class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);
  //* Create Your route observer
  static final RouteObserver<PageRoute> routeObserver = RouteObserver<PageRoute>(); 

  Widget build(BuildContext context) {
    return MaterialApp(
      navigatorObservers: [routeObserver], //* Provide it in navigatorObservers List 
      home: const MyHomePage(title: 'Flutter Route Detector Example'),

class MyHomePage extends StatelessWidget {
  const MyHomePage({Key? key, required this.title}) : super(key: key);
  final String title;
  Widget build(BuildContext context) {
    return RouteDetector( //* Use it
      routeObserver: MyApp.routeObserver,
      routeName: "MyHomePage",
      onLeaveScreen: (){},
      onShowingScreen: (){},
      showLogs: true,
      child: Scaffold(
        appBar: AppBar(
          title: Text(title),
        body: Center(
          child: Text(
            'Screen One',
            style: Theme.of(context).textTheme.headline4,



Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.