buildShadcnDialogTransitions function
Widget
buildShadcnDialogTransitions(
- BuildContext context,
- BorderRadiusGeometry borderRadius,
- AlignmentGeometry alignment,
- Animation<
double> animation, - Animation<
double> secondaryAnimation, - bool fullScreen,
- Widget child,
Builds the enter and exit transition for a shadcn dialog.
The dialog scales up from 70% while fading in, easing out on the way in and
in on the way out. A fullScreen dialog fills the screen and advertises
itself to descendants through ModalContainer.kFullScreenMode; otherwise it
is positioned by alignment.
This is the default used by DialogRoute; pass it to
RawDialogRoute.transitionBuilder to match shadcn dialogs elsewhere.
Parameters:
context(BuildContext, required): Build context.borderRadius(BorderRadiusGeometry, required): Corner radius of the dialog surface.alignment(AlignmentGeometry, required): Where a non-fullscreen dialog sits on screen.animation(Animation<double>, required): Drives this dialog.secondaryAnimation(Animation<double>, required): Drives this dialog as another route covers it.fullScreen(bool, required): Whether the dialog fills the screen.child(Widget, required): The dialog content.
Returns: the transitioned dialog.
Implementation
Widget buildShadcnDialogTransitions(
BuildContext context,
BorderRadiusGeometry borderRadius,
AlignmentGeometry alignment,
Animation<double> animation,
Animation<double> secondaryAnimation,
bool fullScreen,
Widget child,
) {
var scaleTransition = ScaleTransition(
scale: CurvedAnimation(
parent: animation.drive(Tween<double>(begin: 0.7, end: 1.0)),
curve: Curves.easeOut,
reverseCurve: Curves.easeIn,
),
child: FadeTransition(
opacity: CurvedAnimation(parent: animation, curve: Curves.easeOut),
child: child,
),
);
return FocusScope(
child: fullScreen
? MultiModel(
data: const [Model(ModalContainer.kFullScreenMode, true)],
child: scaleTransition,
)
: Align(alignment: alignment, child: scaleTransition),
);
}