customError method

Future<void> customError(
  1. BuildContext context,
  2. String title,
  3. dynamic message
)

Implementation

Future<void> customError(
    BuildContext context, String title, dynamic message) async {
  String defaultMessage = 'Erro desconhecido';

  try {
    if (message is TypeError) {
      defaultMessage = message.toString();
    } else if (message.message != null) {
      defaultMessage = message.message;
    }
  } catch (error) {
    defaultMessage = message;
  }

  return showDialog<void>(
    context: context,
    barrierDismissible: false,
    builder: (BuildContext ctx) {
      return OmegaErrorDialogWidget(
        title: title,
        description: defaultMessage,
        textColor: OmegaLibConfig.dialogFieldStyle.textColor,
        bgColor: OmegaLibConfig.dialogFieldStyle.bgColor,
      );
    },
  );
}