showNUIDialog static method
NUIDialog
showNUIDialog({
- required BuildContext context,
- String? barrierLabel,
- bool dismissible = true,
- Color? barrierColor,
- double opacity = 0.8,
- required DialogBuilder content,
- Alignment alignment = Alignment.center,
- PageTransition? transition,
- bool useSafeArea = true,
- Duration? transitionDuration,
- Function? onDismiss,
Implementation
static NUIDialog showNUIDialog({required BuildContext context, String? barrierLabel, bool dismissible = true, Color? barrierColor, double opacity = 0.8, required DialogBuilder content, Alignment alignment = Alignment.center, PageTransition? transition, bool useSafeArea = true, Duration? transitionDuration, Function? onDismiss}){
NUIDialog dialog = NUIDialog._builder(content: content, label: barrierLabel, dismiss: (Function innerDismiss){
log("NUIDialog -> Dialog dismiss not initiated yet");
});
try {
showGeneralDialog(
barrierLabel: barrierLabel ?? "NUIDialog",
barrierColor: barrierColor ?? Colors.black.withOpacity(opacity ?? 0.8),
barrierDismissible: dismissible ?? true,
transitionDuration: transitionDuration ?? Duration(milliseconds: 250),
context: context,
pageBuilder: (context, animation, secondaryAnimation) {
dialog.dismiss = (Function innerDismiss) {
log("NUIDialog -> Dismissing dialog ... ");
Navigator.pop(context);
if (transitionDuration != null) {
NUIAsync.delay(transitionDuration, () {
if (onDismiss != null) {
onDismiss();
}
innerDismiss();
});
}
else {
if (onDismiss != null) {
onDismiss();
}
innerDismiss();
}
};
return Container(
alignment: alignment ?? Alignment.center,
child: content(context),
);
},
transitionBuilder: (context, animation, secondaryAnimation, child) {
return _getTransition(
context, content(context), transition: transition,
animation: animation,
secondaryAnimation: secondaryAnimation,
child: child);
}
);
}catch(e){
}
return dialog;
}