showNativeDialog static method

Future showNativeDialog({
  1. BuildContext? context,
  2. String title = 'Info',
  3. Material? body,
  4. String message = 'Action cannot be undo.',
  5. String okBtn = 'OK',
  6. String? cancelBtn,
  7. Color? okButtonTextColor,
  8. Color? cancelButtonTextColor,
  9. TextStyle? okButtonTextStyle,
  10. TextStyle? cancelButtonTextStyle,
  11. Widget? okButton,
  12. Widget? cancelButton,
  13. List<Widget>? buttonList,
  14. bool isDismissible = true,
})

Implementation

static Future showNativeDialog({
  BuildContext? context,
  String title = 'Info',
  Material? body,
  String message = 'Action cannot be undo.',
  String okBtn = 'OK',
  String? cancelBtn,
  Color? okButtonTextColor,
  Color? cancelButtonTextColor,
  TextStyle? okButtonTextStyle,
  TextStyle? cancelButtonTextStyle,
  Widget? okButton,
  Widget? cancelButton,
  List<Widget>? buttonList,
  bool isDismissible = true,

}) async {
  return showPlatformDialog(
    context: context ?? Get.context!,
    androidBarrierDismissible: isDismissible,
    useRootNavigator: true,
    builder: (context) => WillPopScope(
      onWillPop: () async => isDismissible,
      child: BasicDialogAlert(
        title: Text(title),
        content: body ?? Text(message),
        actions: buttonList ??
            <Widget>[
              okButton ??
                  BasicDialogAction(
                    title: Text(
                      okBtn,
                      style: okButtonTextStyle ??
                          TextStyle(color: okButtonTextColor),
                    ),
                    onPressed: () =>
                        Get.back(result: cancelBtn == null ? false : true),
                  ),
              if (cancelBtn != null || cancelButton != null)
                cancelButton ??
                    BasicDialogAction(
                      title: Text(
                        cancelBtn ?? '',
                        style: cancelButtonTextStyle ??
                            TextStyle(color: cancelButtonTextColor),
                      ),
                      onPressed: () => Get.back(result: false),
                    ),
            ],
      ),
    ),
  );
}