31

How to do a modal presentation of a route in Flutter?

I figured out how to navigate to a route using the usual "push" transition, but I am struggling to implement a modal transition. See animation attached (done using native iOS). How do I present a screen modally (a screen that itself can be pushed more screens to).

See an example below. The transition I am struggling with is from "A" to "C" (and of course a way to dismiss it and go back to "A").

enter image description here

Nikolay Suvandzhiev
  • 8,465
  • 6
  • 41
  • 47

2 Answers2

44

You can push like this:

Navigator.of(context).push(
        CupertinoPageRoute(
                fullscreenDialog: true,
                builder: (context) => SomePage(),
        ),
);

Hope this helps.

Anit Kumar
  • 8,075
  • 1
  • 24
  • 27
Daibaku
  • 11,416
  • 22
  • 71
  • 108
36

Go to Section B(push) animation can be achieved by following:

Navigator.push(
                context,
                MaterialPageRoute(
                    builder: (context) => SectionBRoute()),
              );

Go to Section C(present modally) animation can be achieved by following:

Navigator.push(
                context,
                MaterialPageRoute(
                    builder: (context) => SectionCRoute(), fullscreenDialog: true),
              );
Mohammad Zaid Pathan
  • 16,304
  • 7
  • 99
  • 130