validate method

  1. @override
void validate()

Validates the properties of the action button.

Throws an AwesomeNotificationsException if the key or label is missing or if the icon is not a native resource media type.

Implementation

@override
void validate() {
  if (AwesomeAssertUtils.isNullOrEmptyOrInvalid(_key)) {
    throw const AwesomeNotificationsException(message: 'key id is required');
  }
  if (AwesomeAssertUtils.isNullOrEmptyOrInvalid(_label)) {
    throw const AwesomeNotificationsException(
        message: 'label id is required');
  }

  // For action buttons, it's only allowed resource media types
  if (!AwesomeStringUtils.isNullOrEmpty(_icon) &&
      AwesomeBitmapUtils().getMediaSource(_icon!) != MediaSource.Resource) {
    throw const AwesomeNotificationsException(
        message:
            'icons for action buttons must be a native resource media type');
  }
}