nonNullAble<T> method

T nonNullAble<T>(
  1. T? argument
)

Makes sure that the CarpApp or CarpUser is configured, by throwing a CarpServiceException if they are null. Otherwise, returns the non-null value.

Implementation

T nonNullAble<T>(T? argument) {
  if (argument == null && argument is CarpApp) {
    throw CarpServiceException(
        message:
            "CARP Service not initialized. Call 'CarpService().configure()' first.");
  } else if (argument == null && argument is CarpUser) {
    throw CarpServiceException(
        message:
            "CARP User not authenticated. Call 'CarpService().authenticate()' first.");
  } else {
    return argument!;
  }
}