Created
December 10, 2019 10:46
-
-
Save shalaby/8c8e54f747b4263658902c4b73d7fd82 to your computer and use it in GitHub Desktop.
Popup route.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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