when<TResult extends Object?> method

  1. @optionalTypeArgs
TResult when<TResult extends Object?>(
  1. TResult $default(
    1. String userID,
    2. String projectSecretKey,
    3. String? userIdSignature,
    4. LocalizedText? welcomeMessage,
    5. LocalizedText? name,
    6. LocalizedText? systemInstructions,
    7. String defaultLocale,
    8. List<String> supportedLocales,
    9. String? currentLocale,
    10. String? allowedOrigins,
    11. String? fontFamily,
    12. String? color,
    13. @unfreezed Uint8List? avatar,
    14. bool isPreviewMode,
    15. bool isReadOnly,
    16. bool showAvatar,
    17. bool hideBarsOnScroll,
    18. bool enableUserExport,
    19. bool enableClearHistory,
    20. bool enableFileAttach,
    21. bool dynamicLanguageEnabled,
    22. bool aiDisclosureEnabled,
    23. LocalizedText? aiDisclosureText,
    24. bool aiDisclosureRequireAck,
    25. bool messageReportingEnabled,
    26. String? aiInfoUrl,
    27. String? privacyUrl,
    28. bool aiDataReuseNotice,
    29. FabConfiguration fabConfiguration,
    30. SoundConfiguration soundConfiguration,
    31. ChatAppearance? chatAppearance,
    32. ChatAppearance? chatAppearanceDark,
    33. bool showThemeToggle,
    34. String defaultThemeMode,
    35. Map<String, dynamic>? userContext,
    36. String? authToken,
    )
)

A switch-like method, using callbacks.

As opposed to map, this offers destructuring. It is equivalent to doing:

switch (sealedClass) {
  case Subclass(:final field):
    return ...;
  case Subclass2(:final field2):
    return ...;
}

Implementation

@optionalTypeArgs TResult when<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 hideBarsOnScroll,  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():
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.hideBarsOnScroll,_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 _:
  throw StateError('Unexpected subclass');

}
}