Install declarative_nav and set up state

Add the package and put the page list and overlay in state. With a single place that updates each stack, it's easier to follow how users move through the app.

Add one package

One pub command adds the package. You can use it as soon as it's installed.

Store the pages and overlay

Keep the pages in a List<PageEntry> and the active overlay in an OverlayRequest? value.

Move one feature at a time

Try it with one feature first. Move the other screens once you're happy with how that stack works.

Install and create the first page stack

Run pub add, then define the first page list and set the initial overlay state.

Add the package

flutter pub add declarative_nav

Example starting state

import 'package:declarative_nav/declarative_nav.dart';

class _AppRootState extends State<AppRoot> {
  OverlayRequest? _overlay;
  late List<PageEntry> _pages;

  @override
  void initState() {
    super.initState();
    _pages = const [
      PageEntry(key: 'home', name: '/home'),
    ];
  }
}
Keep keys unique within the stack

Give each page in a stack a unique PageEntry.key so the Navigator can tell those pages apart.