Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
117 additions
and
72 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,40 +1,43 @@ | ||
|
||
import 'package:flutter/material.dart'; | ||
|
||
///{@template custom hero_dialod_route} | ||
///Custom [PageRoute] that creates an overlay dialog popup effect | ||
/// | ||
///Best used with a [Hero] animation | ||
class CustomHeroDialogRoute<T> extends PageRoute<T> { | ||
|
||
CustomHeroDialogRoute({ | ||
@required WidgetBuilder builder, | ||
RouteSettings settings, | ||
bool fullscreenDialog = false, | ||
}) : _builder = builder, super(settings: settings, fullscreenDialog: fullscreenDialog); | ||
|
||
final WidgetBuilder _builder; | ||
|
||
@override | ||
bool get opaque => false; | ||
@override | ||
bool get barrierDismissible => true; | ||
@override | ||
Duration get transitionDuration => const Duration(milliseconds:300); | ||
@override | ||
bool get maintainState=> true; | ||
|
||
@override | ||
Color get barrierColor => Colors.black54; | ||
@override | ||
Widget buildTransitions(BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation, Widget child){ return child;} | ||
|
||
@override | ||
Widget buildPage(BuildContext context, Animation<double> animation, Animation<double> secondaryAnimation){ | ||
return _builder(context); | ||
class CustomHeroDialogRoute<T> extends PageRoute<T> { | ||
CustomHeroDialogRoute({ | ||
@required WidgetBuilder builder, | ||
RouteSettings settings, | ||
bool fullscreenDialog = false, | ||
}) : _builder = builder, | ||
super(settings: settings, fullscreenDialog: fullscreenDialog); | ||
|
||
final WidgetBuilder _builder; | ||
|
||
@override | ||
bool get opaque => false; | ||
@override | ||
bool get barrierDismissible => true; | ||
@override | ||
Duration get transitionDuration => const Duration(milliseconds: 300); | ||
@override | ||
bool get maintainState => true; | ||
|
||
@override | ||
Color get barrierColor => Colors.black54; | ||
@override | ||
Widget buildTransitions(BuildContext context, Animation<double> animation, | ||
Animation<double> secondaryAnimation, Widget child) { | ||
return child; | ||
} | ||
|
||
@override | ||
Widget buildPage(BuildContext context, Animation<double> animation, | ||
Animation<double> secondaryAnimation) { | ||
return _builder(context); | ||
} | ||
|
||
@override | ||
String get barrierLabel => 'Popup dialog open'; | ||
} | ||
@override | ||
String get barrierLabel => 'Popup dialog open'; | ||
|
||
} |
This file contains 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