showWidget function
dynamic
showWidget(})
Implementation
showWidget(
BuildContext context,
Widget widget,
String routeName, {
Object? routeArguments,
void Function(dynamic value)? onClose,
void Function()? onBeforeShow,
bool? progress = true,
bool? forceRoute = false,
}) {
if (onBeforeShow != null) {
onBeforeShow();
}
if (getScreenResolution(context) >= ScreenResolutions.md &&
forceRoute != true) {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
contentPadding: EdgeInsets.zero,
content: Container(
width: MediaQuery.of(context).size.width,
constraints: const BoxConstraints(
maxWidth: 600,
),
child: widget,
),
);
},
).then((value) {
if (onClose != null) {
onClose(value);
}
});
} else {
Navigator.pushNamed(
context,
routeName,
arguments: routeArguments,
).then((value) {
if (onClose != null) {
onClose(value);
}
});
}
}