showAppDialog static method

void showAppDialog({
  1. required BuildContext context,
  2. required String title,
  3. required String message,
  4. required String closeMsg,
  5. required ImageProvider<Object> imageProvided,
  6. bool withIcon = true,
})

Implementation

static void showAppDialog(
    {required BuildContext context,
    required String title,
    required String message,
    required String closeMsg,
    required ImageProvider imageProvided,
    bool withIcon = true}) {
  showDialog(
    context: context,
    builder: (BuildContext context) {
      // return object of type Dialog
      return AlertDialog(
        elevation: 2,
        shape: const RoundedRectangleBorder(
            borderRadius: BorderRadius.all(Radius.circular(20.0))),
        title: Text(title,
            style: Theme.of(context).textTheme.bodyLarge!.apply(
                  fontSizeFactor: 1.6,
                )),
        content: SizedBox(
          height: MediaQuery.of(context).size.height *
              0.25 *
              (message.length > 150 && withIcon ? 1.8 : 1),
          width:
              MediaQuery.of(context).size.width * 0.6 * (withIcon ? 1.2 : 1),
          child: withIcon
              ? _appDialogContentWithImage(
                  context: context,
                  message: message,
                  imageProvided: imageProvided)
              : _appDialogContentWithoutImage(
                  context: context,
                  message: message,
                  imageProvided: imageProvided),
        ),
        actions: <Widget>[
          TextButton(
            child: Text(closeMsg),
            onPressed: () => Navigator.of(context).pop(),
          ),
        ],
      );
    },
  );
}