createRoute method
Creates the route for the dialog page.
It uses RawDialogRoute to provide a custom transition and look for the dialog page based on the media type of the device.
Implementation
@override
/// Creates the route for the dialog page.
///
/// It uses [RawDialogRoute] to provide a custom transition and look
/// for the dialog page based on the media type of the device.
Route<T> createRoute(BuildContext context) {
final mediaLayoutBloc = FastMediaLayoutBloc.instance;
final currentMediaType = mediaLayoutBloc.currentState.mediaType;
if (currentMediaType == FastMediaType.handset) {
return MaterialPageRoute<T>(
builder: (context) => child,
fullscreenDialog: true,
settings: this,
);
}
return RawDialogRoute<T>(
transitionDuration: const Duration(milliseconds: 300),
transitionBuilder: buildTransition,
barrierDismissible: true,
settings: this,
pageBuilder: (context, animation, secondaryAnimation) {
return SafeArea(
child: Dialog(
clipBehavior: Clip.antiAlias,
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(8.0)),
),
child: FastMediaLayoutBuilder(builder: (context, mediaType) {
return LayoutBuilder(builder: (context, constraints) {
return FractionallySizedBox(
heightFactor: _getDialogHeight(mediaType, constraints),
widthFactor: _getDialogWidth(mediaType),
child: child,
);
});
}),
),
);
},
);
}