Skip to content

Instantly share code, notes, and snippets.

@shalaby
Created December 10, 2019 10:46
Show Gist options
  • Save shalaby/8c8e54f747b4263658902c4b73d7fd82 to your computer and use it in GitHub Desktop.
Save shalaby/8c8e54f747b4263658902c4b73d7fd82 to your computer and use it in GitHub Desktop.
Popup route.
PopupRoute
I read flutter framework code and found out showDialog is actually using PopupRoute. Basically, this will create a new route and make the previous routepage inactive.
The simplest code is as follows:
class MyPopupRoute extends PopupRoute<void> {
@override
Color get barrierColor => Colors.black54;
@override
bool get barrierDismissible => true;
@override
String get barrierLabel => "Close";
@override
Widget buildPage(BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation) => MyPopupPage();
@override
Duration get transitionDuration => const Duration(milliseconds: 300);
}
where MyPopupPage is the new popup widget.
If you want animations, you can override the method buildTransitions method.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment