Skip to content

Instantly share code, notes, and snippets.

@rutvik110
Last active February 25, 2022 03:18
Show Gist options
  • Save rutvik110/d9b1a09f8ee77032faf66cee1c5bdf1a to your computer and use it in GitHub Desktop.
Save rutvik110/d9b1a09f8ee77032faf66cee1c5bdf1a to your computer and use it in GitHub Desktop.
For Hero Transitions Within Dialogs
import 'package:chaseapp/src/const/other.dart';
import 'package:flutter/material.dart';
// https://github.com/flutter/flutter/issues/10667
// Navigator.push(
// context,
// HeroDialogRoute<void>(
// builder: (context) {
// return Dialog();
// },
// ),
// );
class HeroDialogRoute<T> extends PageRoute<T> {
HeroDialogRoute({required this.builder}) : super();
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 new FadeTransition(
opacity: new CurvedAnimation(
parent: animation,
curve: primaryCurve,
),
child: child,
);
}
@override
Widget buildPage(BuildContext context, Animation<double> animation,
Animation<double> secondaryAnimation) {
return builder(context);
}
@override
// TODO: implement barrierLabel
String? get barrierLabel => "Dismissable Dialog";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment