whenOrNull<TResult extends Object?> method
TResult?
whenOrNull<TResult extends Object?>(
- TResult? $default(
- bool showErrorMsg,
- String loadingText,
- String? contentType,
- Map<
String, dynamic> headers, - bool showDefaultLoading,
- @JsonKey.new(name: 'data', toJson: _dataToJson) dynamic data,
- ResponseType? responseType,
- bool? nullParams,
- @igFreezedJson RequestEncoder? requestEncoder,
- @igFreezedJson DioStart? dioStart,
- bool? returnIsString,
- @igFreezedJson String? fullUrl,
- @igFreezedJson InterceptorCall? interceptorCall,
- @igFreezedJson UrlParseFormat? urlParseFormat,
- @igFreezedJson ResponseResultCallback? responseResultCallback,
- Map<
String, dynamic> ? extra, - @igFreezedJson CancelToken? cancelToken,
- @igFreezedJson ProgressCallback? onSendCallback,
- @igFreezedJson ProgressCallback? onReceiveProgress,
- String? downloadUrl,
- @igFreezedJson File? savePath,
A variant of when that fallback to returning null
It is equivalent to doing:
switch (sealedClass) {
case Subclass(:final field):
return ...;
case _:
return null;
}
Implementation
@optionalTypeArgs
TResult? whenOrNull<TResult extends Object?>(
TResult? Function(
bool showErrorMsg,
String loadingText,
String? contentType,
Map<String, dynamic> headers,
bool showDefaultLoading,
@JsonKey(name: 'data', toJson: _dataToJson) dynamic data,
ResponseType? responseType,
bool? nullParams,
@igFreezedJson RequestEncoder? requestEncoder,
@igFreezedJson DioStart? dioStart,
bool? returnIsString,
@igFreezedJson String? fullUrl,
@igFreezedJson InterceptorCall? interceptorCall,
@igFreezedJson UrlParseFormat? urlParseFormat,
@igFreezedJson ResponseResultCallback? responseResultCallback,
Map<String, dynamic>? extra,
@igFreezedJson CancelToken? cancelToken,
@igFreezedJson ProgressCallback? onSendCallback,
@igFreezedJson ProgressCallback? onReceiveProgress,
String? downloadUrl,
@igFreezedJson File? savePath)?
$default,
) {
final _that = this;
switch (_that) {
case _RequestParams() when $default != null:
return $default(
_that.showErrorMsg,
_that.loadingText,
_that.contentType,
_that.headers,
_that.showDefaultLoading,
_that.data,
_that.responseType,
_that.nullParams,
_that.requestEncoder,
_that.dioStart,
_that.returnIsString,
_that.fullUrl,
_that.interceptorCall,
_that.urlParseFormat,
_that.responseResultCallback,
_that.extra,
_that.cancelToken,
_that.onSendCallback,
_that.onReceiveProgress,
_that.downloadUrl,
_that.savePath);
case _:
return null;
}
}