whenOrNull<TResult extends Object?> method
TResult?
whenOrNull<TResult extends Object?>(
- TResult? $default(
- String userID,
- String projectSecretKey,
- String? userIdSignature,
- LocalizedText? welcomeMessage,
- LocalizedText? name,
- LocalizedText? systemInstructions,
- String defaultLocale,
- List<
String> supportedLocales, - String? currentLocale,
- String? allowedOrigins,
- String? fontFamily,
- String? color,
- @unfreezed Uint8List? avatar,
- bool isPreviewMode,
- bool isReadOnly,
- bool showAvatar,
- bool enableUserExport,
- bool enableClearHistory,
- bool enableFileAttach,
- bool dynamicLanguageEnabled,
- bool aiDisclosureEnabled,
- LocalizedText? aiDisclosureText,
- bool aiDisclosureRequireAck,
- bool messageReportingEnabled,
- String? aiInfoUrl,
- String? privacyUrl,
- bool aiDataReuseNotice,
- FabConfiguration fabConfiguration,
- SoundConfiguration soundConfiguration,
- ChatAppearance? chatAppearance,
- ChatAppearance? chatAppearanceDark,
- bool showThemeToggle,
- String defaultThemeMode,
- Map<
String, dynamic> ? userContext, - String? authToken,
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( String userID, String projectSecretKey, String? userIdSignature, LocalizedText? welcomeMessage, LocalizedText? name, LocalizedText? systemInstructions, String defaultLocale, List<String> supportedLocales, String? currentLocale, String? allowedOrigins, String? fontFamily, String? color, @unfreezed Uint8List? avatar, bool isPreviewMode, bool isReadOnly, bool showAvatar, bool enableUserExport, bool enableClearHistory, bool enableFileAttach, bool dynamicLanguageEnabled, bool aiDisclosureEnabled, LocalizedText? aiDisclosureText, bool aiDisclosureRequireAck, bool messageReportingEnabled, String? aiInfoUrl, String? privacyUrl, bool aiDataReuseNotice, FabConfiguration fabConfiguration, SoundConfiguration soundConfiguration, ChatAppearance? chatAppearance, ChatAppearance? chatAppearanceDark, bool showThemeToggle, String defaultThemeMode, Map<String, dynamic>? userContext, String? authToken)? $default,) {final _that = this;
switch (_that) {
case _BotConfiguration() when $default != null:
return $default(_that.userID,_that.projectSecretKey,_that.userIdSignature,_that.welcomeMessage,_that.name,_that.systemInstructions,_that.defaultLocale,_that.supportedLocales,_that.currentLocale,_that.allowedOrigins,_that.fontFamily,_that.color,_that.avatar,_that.isPreviewMode,_that.isReadOnly,_that.showAvatar,_that.enableUserExport,_that.enableClearHistory,_that.enableFileAttach,_that.dynamicLanguageEnabled,_that.aiDisclosureEnabled,_that.aiDisclosureText,_that.aiDisclosureRequireAck,_that.messageReportingEnabled,_that.aiInfoUrl,_that.privacyUrl,_that.aiDataReuseNotice,_that.fabConfiguration,_that.soundConfiguration,_that.chatAppearance,_that.chatAppearanceDark,_that.showThemeToggle,_that.defaultThemeMode,_that.userContext,_that.authToken);case _:
return null;
}
}