throwUncheckedIfNull method

T throwUncheckedIfNull( {
  1. required String prefix,
  2. ({String english, String locale}) message = (english: '', locale: ''),
  3. StackTrace? stackTrace,
})

데이터가 null일 경우 UncheckedError를 발생시키고, 아닐 경우 Non-nullable 값을 반환합니다.

절대 null일 수 없는 내부 상태나 DI 객체가 누락된 치명적 상황에서 사용합니다. 발생 시점의 타입 정보(T)를 포함하여 프로그래머의 실수를 빠르게 식별할 수 있도록 돕습니다.

Throws an UncheckedError if the value is null, otherwise returns the non-nullable value. Includes type T information to help identify programmer errors quickly.

Implementation

T throwUncheckedIfNull({
  required String prefix,
  ({String english, String locale}) message = (english: '', locale: ''),
  StackTrace? stackTrace,
}) {
  if (this == null) {
    throw GenericUncheckedError(
      value: this,
      prefix: prefix,
      message: message,
      stackTrace: stackTrace ?? StackTrace.current,
    );
  }
  return this as T;
}