Add the Flutter video editing application with project management, media import, timeline editing, preview, AI assistance, diagnostics and settings. Include shared UI and native host packages, platform runners, application tests and release tooling. Provide usage and contribution guides, the MIT license and third-party notices. Exclude local credentials, build outputs and validation data.
936 lines
25 KiB
Dart
936 lines
25 KiB
Dart
// GENERATED CODE - DO NOT MODIFY BY HAND
|
|
// coverage:ignore-file
|
|
// ignore_for_file: type=lint, type=warning, deprecated_member_use, deprecated_member_use_from_same_package
|
|
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
|
|
|
part of 'chat_state.dart';
|
|
|
|
// **************************************************************************
|
|
// FreezedGenerator
|
|
// **************************************************************************
|
|
|
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
|
T _$identity<T>(T value) => value;
|
|
|
|
/// @nodoc
|
|
mixin _$ChatMessage {
|
|
String get text;
|
|
bool get isUser;
|
|
bool get interrupted;
|
|
int? get elapsedMs;
|
|
|
|
/// Create a copy of ChatMessage
|
|
/// with the given fields replaced by the non-null parameter values.
|
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
@pragma('vm:prefer-inline')
|
|
$ChatMessageCopyWith<ChatMessage> get copyWith =>
|
|
_$ChatMessageCopyWithImpl<ChatMessage>(this as ChatMessage, _$identity);
|
|
|
|
@override
|
|
bool operator ==(Object other) {
|
|
final _this = this as ChatMessage;
|
|
return identical(this, other) ||
|
|
(other.runtimeType == runtimeType &&
|
|
other is ChatMessage &&
|
|
(identical(other.text, _this.text) || other.text == _this.text) &&
|
|
(identical(other.isUser, _this.isUser) ||
|
|
other.isUser == _this.isUser) &&
|
|
(identical(other.interrupted, _this.interrupted) ||
|
|
other.interrupted == _this.interrupted) &&
|
|
(identical(other.elapsedMs, _this.elapsedMs) ||
|
|
other.elapsedMs == _this.elapsedMs));
|
|
}
|
|
|
|
@override
|
|
int get hashCode {
|
|
final _this = this as ChatMessage;
|
|
return Object.hash(
|
|
runtimeType,
|
|
_this.text,
|
|
_this.isUser,
|
|
_this.interrupted,
|
|
_this.elapsedMs,
|
|
);
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
final _this = this as ChatMessage;
|
|
return 'ChatMessage(text: ${_this.text}, isUser: ${_this.isUser}, interrupted: ${_this.interrupted}, elapsedMs: ${_this.elapsedMs})';
|
|
}
|
|
}
|
|
|
|
/// @nodoc
|
|
abstract mixin class $ChatMessageCopyWith<$Res> {
|
|
factory $ChatMessageCopyWith(
|
|
ChatMessage value,
|
|
$Res Function(ChatMessage) _then,
|
|
) = _$ChatMessageCopyWithImpl;
|
|
@useResult
|
|
$Res call({String text, bool isUser, bool interrupted, int? elapsedMs});
|
|
}
|
|
|
|
/// @nodoc
|
|
class _$ChatMessageCopyWithImpl<$Res> implements $ChatMessageCopyWith<$Res> {
|
|
_$ChatMessageCopyWithImpl(this._self, this._then);
|
|
|
|
final ChatMessage _self;
|
|
final $Res Function(ChatMessage) _then;
|
|
|
|
/// Create a copy of ChatMessage
|
|
/// with the given fields replaced by the non-null parameter values.
|
|
@pragma('vm:prefer-inline')
|
|
@override
|
|
$Res call({
|
|
Object? text = null,
|
|
Object? isUser = null,
|
|
Object? interrupted = null,
|
|
Object? elapsedMs = freezed,
|
|
}) {
|
|
return _then(
|
|
ChatMessage(
|
|
text: null == text
|
|
? _self.text
|
|
: text // ignore: cast_nullable_to_non_nullable
|
|
as String,
|
|
isUser: null == isUser
|
|
? _self.isUser
|
|
: isUser // ignore: cast_nullable_to_non_nullable
|
|
as bool,
|
|
interrupted: null == interrupted
|
|
? _self.interrupted
|
|
: interrupted // ignore: cast_nullable_to_non_nullable
|
|
as bool,
|
|
elapsedMs: freezed == elapsedMs
|
|
? _self.elapsedMs
|
|
: elapsedMs // ignore: cast_nullable_to_non_nullable
|
|
as int?,
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// Adds pattern-matching-related methods to [ChatMessage].
|
|
extension ChatMessagePatterns on ChatMessage {
|
|
/// A variant of `map` that fallback to returning `orElse`.
|
|
///
|
|
/// It is equivalent to doing:
|
|
/// ```dart
|
|
/// switch (sealedClass) {
|
|
/// case final Subclass value:
|
|
/// return ...;
|
|
/// case _:
|
|
/// return orElse();
|
|
/// }
|
|
/// ```
|
|
|
|
@optionalTypeArgs
|
|
TResult maybeMap<TResult extends Object?>(
|
|
TResult Function(_ChatMessage value)? $default, {
|
|
required TResult orElse(),
|
|
}) {
|
|
final _that = this;
|
|
switch (_that) {
|
|
case _ChatMessage() when $default != null:
|
|
return $default(_that);
|
|
case _:
|
|
return orElse();
|
|
}
|
|
}
|
|
|
|
/// A `switch`-like method, using callbacks.
|
|
///
|
|
/// Callbacks receives the raw object, upcasted.
|
|
/// It is equivalent to doing:
|
|
/// ```dart
|
|
/// switch (sealedClass) {
|
|
/// case final Subclass value:
|
|
/// return ...;
|
|
/// case final Subclass2 value:
|
|
/// return ...;
|
|
/// }
|
|
/// ```
|
|
|
|
@optionalTypeArgs
|
|
TResult map<TResult extends Object?>(
|
|
TResult Function(_ChatMessage value) $default,
|
|
) {
|
|
final _that = this;
|
|
switch (_that) {
|
|
case _ChatMessage():
|
|
return $default(_that);
|
|
case _:
|
|
throw StateError('Unexpected subclass');
|
|
}
|
|
}
|
|
|
|
/// A variant of `map` that fallback to returning `null`.
|
|
///
|
|
/// It is equivalent to doing:
|
|
/// ```dart
|
|
/// switch (sealedClass) {
|
|
/// case final Subclass value:
|
|
/// return ...;
|
|
/// case _:
|
|
/// return null;
|
|
/// }
|
|
/// ```
|
|
|
|
@optionalTypeArgs
|
|
TResult? mapOrNull<TResult extends Object?>(
|
|
TResult? Function(_ChatMessage value)? $default,
|
|
) {
|
|
final _that = this;
|
|
switch (_that) {
|
|
case _ChatMessage() when $default != null:
|
|
return $default(_that);
|
|
case _:
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/// A variant of `when` that fallback to an `orElse` callback.
|
|
///
|
|
/// It is equivalent to doing:
|
|
/// ```dart
|
|
/// switch (sealedClass) {
|
|
/// case Subclass(:final field):
|
|
/// return ...;
|
|
/// case _:
|
|
/// return orElse();
|
|
/// }
|
|
/// ```
|
|
|
|
@optionalTypeArgs
|
|
TResult maybeWhen<TResult extends Object?>(
|
|
TResult Function(
|
|
String text,
|
|
bool isUser,
|
|
bool interrupted,
|
|
int? elapsedMs,
|
|
)?
|
|
$default, {
|
|
required TResult orElse(),
|
|
}) {
|
|
final _that = this;
|
|
switch (_that) {
|
|
case _ChatMessage() when $default != null:
|
|
return $default(
|
|
_that.text,
|
|
_that.isUser,
|
|
_that.interrupted,
|
|
_that.elapsedMs,
|
|
);
|
|
case _:
|
|
return orElse();
|
|
}
|
|
}
|
|
|
|
/// A `switch`-like method, using callbacks.
|
|
///
|
|
/// As opposed to `map`, this offers destructuring.
|
|
/// It is equivalent to doing:
|
|
/// ```dart
|
|
/// switch (sealedClass) {
|
|
/// case Subclass(:final field):
|
|
/// return ...;
|
|
/// case Subclass2(:final field2):
|
|
/// return ...;
|
|
/// }
|
|
/// ```
|
|
|
|
@optionalTypeArgs
|
|
TResult when<TResult extends Object?>(
|
|
TResult Function(String text, bool isUser, bool interrupted, int? elapsedMs)
|
|
$default,
|
|
) {
|
|
final _that = this;
|
|
switch (_that) {
|
|
case _ChatMessage():
|
|
return $default(
|
|
_that.text,
|
|
_that.isUser,
|
|
_that.interrupted,
|
|
_that.elapsedMs,
|
|
);
|
|
case _:
|
|
throw StateError('Unexpected subclass');
|
|
}
|
|
}
|
|
|
|
/// A variant of `when` that fallback to returning `null`
|
|
///
|
|
/// It is equivalent to doing:
|
|
/// ```dart
|
|
/// switch (sealedClass) {
|
|
/// case Subclass(:final field):
|
|
/// return ...;
|
|
/// case _:
|
|
/// return null;
|
|
/// }
|
|
/// ```
|
|
|
|
@optionalTypeArgs
|
|
TResult? whenOrNull<TResult extends Object?>(
|
|
TResult? Function(
|
|
String text,
|
|
bool isUser,
|
|
bool interrupted,
|
|
int? elapsedMs,
|
|
)?
|
|
$default,
|
|
) {
|
|
final _that = this;
|
|
switch (_that) {
|
|
case _ChatMessage() when $default != null:
|
|
return $default(
|
|
_that.text,
|
|
_that.isUser,
|
|
_that.interrupted,
|
|
_that.elapsedMs,
|
|
);
|
|
case _:
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// @nodoc
|
|
|
|
class _ChatMessage implements ChatMessage {
|
|
const _ChatMessage({
|
|
required this.text,
|
|
this.isUser = false,
|
|
this.interrupted = false,
|
|
this.elapsedMs,
|
|
});
|
|
|
|
@override
|
|
final String text;
|
|
@override
|
|
@JsonKey()
|
|
final bool isUser;
|
|
@override
|
|
@JsonKey()
|
|
final bool interrupted;
|
|
@override
|
|
final int? elapsedMs;
|
|
|
|
/// Create a copy of ChatMessage
|
|
/// with the given fields replaced by the non-null parameter values.
|
|
@override
|
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
@pragma('vm:prefer-inline')
|
|
_$ChatMessageCopyWith<_ChatMessage> get copyWith =>
|
|
__$ChatMessageCopyWithImpl<_ChatMessage>(this, _$identity);
|
|
|
|
@override
|
|
bool operator ==(Object other) {
|
|
return identical(this, other) ||
|
|
(other.runtimeType == runtimeType &&
|
|
other is _ChatMessage &&
|
|
(identical(other.text, text) || other.text == text) &&
|
|
(identical(other.isUser, isUser) || other.isUser == isUser) &&
|
|
(identical(other.interrupted, interrupted) ||
|
|
other.interrupted == interrupted) &&
|
|
(identical(other.elapsedMs, elapsedMs) ||
|
|
other.elapsedMs == elapsedMs));
|
|
}
|
|
|
|
@override
|
|
int get hashCode {
|
|
return Object.hash(runtimeType, text, isUser, interrupted, elapsedMs);
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return 'ChatMessage(text: $text, isUser: $isUser, interrupted: $interrupted, elapsedMs: $elapsedMs)';
|
|
}
|
|
}
|
|
|
|
/// @nodoc
|
|
abstract mixin class _$ChatMessageCopyWith<$Res>
|
|
implements $ChatMessageCopyWith<$Res> {
|
|
factory _$ChatMessageCopyWith(
|
|
_ChatMessage value,
|
|
$Res Function(_ChatMessage) _then,
|
|
) = __$ChatMessageCopyWithImpl;
|
|
@override
|
|
@useResult
|
|
$Res call({String text, bool isUser, bool interrupted, int? elapsedMs});
|
|
}
|
|
|
|
/// @nodoc
|
|
class __$ChatMessageCopyWithImpl<$Res> implements _$ChatMessageCopyWith<$Res> {
|
|
__$ChatMessageCopyWithImpl(this._self, this._then);
|
|
|
|
final _ChatMessage _self;
|
|
final $Res Function(_ChatMessage) _then;
|
|
|
|
/// Create a copy of ChatMessage
|
|
/// with the given fields replaced by the non-null parameter values.
|
|
@override
|
|
@pragma('vm:prefer-inline')
|
|
$Res call({
|
|
Object? text = null,
|
|
Object? isUser = null,
|
|
Object? interrupted = null,
|
|
Object? elapsedMs = freezed,
|
|
}) {
|
|
return _then(
|
|
_ChatMessage(
|
|
text: null == text
|
|
? _self.text
|
|
: text // ignore: cast_nullable_to_non_nullable
|
|
as String,
|
|
isUser: null == isUser
|
|
? _self.isUser
|
|
: isUser // ignore: cast_nullable_to_non_nullable
|
|
as bool,
|
|
interrupted: null == interrupted
|
|
? _self.interrupted
|
|
: interrupted // ignore: cast_nullable_to_non_nullable
|
|
as bool,
|
|
elapsedMs: freezed == elapsedMs
|
|
? _self.elapsedMs
|
|
: elapsedMs // ignore: cast_nullable_to_non_nullable
|
|
as int?,
|
|
),
|
|
);
|
|
}
|
|
}
|
|
|
|
/// @nodoc
|
|
mixin _$ChatState {
|
|
List<ChatMessage> get messages;
|
|
String get partialResponse;
|
|
AgentChatActivity get activity;
|
|
bool get busy;
|
|
bool get stopping;
|
|
AgentChatError? get error;
|
|
ConversationMetadata? get conversation;
|
|
|
|
/// Create a copy of ChatState
|
|
/// with the given fields replaced by the non-null parameter values.
|
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
@pragma('vm:prefer-inline')
|
|
$ChatStateCopyWith<ChatState> get copyWith =>
|
|
_$ChatStateCopyWithImpl<ChatState>(this as ChatState, _$identity);
|
|
|
|
@override
|
|
bool operator ==(Object other) {
|
|
final _this = this as ChatState;
|
|
return identical(this, other) ||
|
|
(other.runtimeType == runtimeType &&
|
|
other is ChatState &&
|
|
const DeepCollectionEquality().equals(
|
|
other.messages,
|
|
_this.messages,
|
|
) &&
|
|
(identical(other.partialResponse, _this.partialResponse) ||
|
|
other.partialResponse == _this.partialResponse) &&
|
|
(identical(other.activity, _this.activity) ||
|
|
other.activity == _this.activity) &&
|
|
(identical(other.busy, _this.busy) || other.busy == _this.busy) &&
|
|
(identical(other.stopping, _this.stopping) ||
|
|
other.stopping == _this.stopping) &&
|
|
(identical(other.error, _this.error) ||
|
|
other.error == _this.error) &&
|
|
(identical(other.conversation, _this.conversation) ||
|
|
other.conversation == _this.conversation));
|
|
}
|
|
|
|
@override
|
|
int get hashCode {
|
|
final _this = this as ChatState;
|
|
return Object.hash(
|
|
runtimeType,
|
|
const DeepCollectionEquality().hash(_this.messages),
|
|
_this.partialResponse,
|
|
_this.activity,
|
|
_this.busy,
|
|
_this.stopping,
|
|
_this.error,
|
|
_this.conversation,
|
|
);
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
final _this = this as ChatState;
|
|
return 'ChatState(messages: ${_this.messages}, partialResponse: ${_this.partialResponse}, activity: ${_this.activity}, busy: ${_this.busy}, stopping: ${_this.stopping}, error: ${_this.error}, conversation: ${_this.conversation})';
|
|
}
|
|
}
|
|
|
|
/// @nodoc
|
|
abstract mixin class $ChatStateCopyWith<$Res> {
|
|
factory $ChatStateCopyWith(ChatState value, $Res Function(ChatState) _then) =
|
|
_$ChatStateCopyWithImpl;
|
|
@useResult
|
|
$Res call({
|
|
List<ChatMessage> messages,
|
|
String partialResponse,
|
|
AgentChatActivity activity,
|
|
bool busy,
|
|
bool stopping,
|
|
AgentChatError? error,
|
|
ConversationMetadata? conversation,
|
|
});
|
|
|
|
$ConversationMetadataCopyWith<$Res>? get conversation;
|
|
}
|
|
|
|
/// @nodoc
|
|
class _$ChatStateCopyWithImpl<$Res> implements $ChatStateCopyWith<$Res> {
|
|
_$ChatStateCopyWithImpl(this._self, this._then);
|
|
|
|
final ChatState _self;
|
|
final $Res Function(ChatState) _then;
|
|
|
|
/// Create a copy of ChatState
|
|
/// with the given fields replaced by the non-null parameter values.
|
|
@pragma('vm:prefer-inline')
|
|
@override
|
|
$Res call({
|
|
Object? messages = null,
|
|
Object? partialResponse = null,
|
|
Object? activity = null,
|
|
Object? busy = null,
|
|
Object? stopping = null,
|
|
Object? error = freezed,
|
|
Object? conversation = freezed,
|
|
}) {
|
|
return _then(
|
|
ChatState(
|
|
messages: null == messages
|
|
? _self.messages
|
|
: messages // ignore: cast_nullable_to_non_nullable
|
|
as List<ChatMessage>,
|
|
partialResponse: null == partialResponse
|
|
? _self.partialResponse
|
|
: partialResponse // ignore: cast_nullable_to_non_nullable
|
|
as String,
|
|
activity: null == activity
|
|
? _self.activity
|
|
: activity // ignore: cast_nullable_to_non_nullable
|
|
as AgentChatActivity,
|
|
busy: null == busy
|
|
? _self.busy
|
|
: busy // ignore: cast_nullable_to_non_nullable
|
|
as bool,
|
|
stopping: null == stopping
|
|
? _self.stopping
|
|
: stopping // ignore: cast_nullable_to_non_nullable
|
|
as bool,
|
|
error: freezed == error
|
|
? _self.error
|
|
: error // ignore: cast_nullable_to_non_nullable
|
|
as AgentChatError?,
|
|
conversation: freezed == conversation
|
|
? _self.conversation
|
|
: conversation // ignore: cast_nullable_to_non_nullable
|
|
as ConversationMetadata?,
|
|
),
|
|
);
|
|
}
|
|
|
|
/// Create a copy of ChatState
|
|
/// with the given fields replaced by the non-null parameter values.
|
|
@override
|
|
@pragma('vm:prefer-inline')
|
|
$ConversationMetadataCopyWith<$Res>? get conversation {
|
|
if (_self.conversation == null) {
|
|
return null;
|
|
}
|
|
|
|
return $ConversationMetadataCopyWith<$Res>(_self.conversation!, (value) {
|
|
return _then(_self.copyWith(conversation: value));
|
|
});
|
|
}
|
|
}
|
|
|
|
/// Adds pattern-matching-related methods to [ChatState].
|
|
extension ChatStatePatterns on ChatState {
|
|
/// A variant of `map` that fallback to returning `orElse`.
|
|
///
|
|
/// It is equivalent to doing:
|
|
/// ```dart
|
|
/// switch (sealedClass) {
|
|
/// case final Subclass value:
|
|
/// return ...;
|
|
/// case _:
|
|
/// return orElse();
|
|
/// }
|
|
/// ```
|
|
|
|
@optionalTypeArgs
|
|
TResult maybeMap<TResult extends Object?>(
|
|
TResult Function(_ChatState value)? $default, {
|
|
required TResult orElse(),
|
|
}) {
|
|
final _that = this;
|
|
switch (_that) {
|
|
case _ChatState() when $default != null:
|
|
return $default(_that);
|
|
case _:
|
|
return orElse();
|
|
}
|
|
}
|
|
|
|
/// A `switch`-like method, using callbacks.
|
|
///
|
|
/// Callbacks receives the raw object, upcasted.
|
|
/// It is equivalent to doing:
|
|
/// ```dart
|
|
/// switch (sealedClass) {
|
|
/// case final Subclass value:
|
|
/// return ...;
|
|
/// case final Subclass2 value:
|
|
/// return ...;
|
|
/// }
|
|
/// ```
|
|
|
|
@optionalTypeArgs
|
|
TResult map<TResult extends Object?>(
|
|
TResult Function(_ChatState value) $default,
|
|
) {
|
|
final _that = this;
|
|
switch (_that) {
|
|
case _ChatState():
|
|
return $default(_that);
|
|
case _:
|
|
throw StateError('Unexpected subclass');
|
|
}
|
|
}
|
|
|
|
/// A variant of `map` that fallback to returning `null`.
|
|
///
|
|
/// It is equivalent to doing:
|
|
/// ```dart
|
|
/// switch (sealedClass) {
|
|
/// case final Subclass value:
|
|
/// return ...;
|
|
/// case _:
|
|
/// return null;
|
|
/// }
|
|
/// ```
|
|
|
|
@optionalTypeArgs
|
|
TResult? mapOrNull<TResult extends Object?>(
|
|
TResult? Function(_ChatState value)? $default,
|
|
) {
|
|
final _that = this;
|
|
switch (_that) {
|
|
case _ChatState() when $default != null:
|
|
return $default(_that);
|
|
case _:
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/// A variant of `when` that fallback to an `orElse` callback.
|
|
///
|
|
/// It is equivalent to doing:
|
|
/// ```dart
|
|
/// switch (sealedClass) {
|
|
/// case Subclass(:final field):
|
|
/// return ...;
|
|
/// case _:
|
|
/// return orElse();
|
|
/// }
|
|
/// ```
|
|
|
|
@optionalTypeArgs
|
|
TResult maybeWhen<TResult extends Object?>(
|
|
TResult Function(
|
|
List<ChatMessage> messages,
|
|
String partialResponse,
|
|
AgentChatActivity activity,
|
|
bool busy,
|
|
bool stopping,
|
|
AgentChatError? error,
|
|
ConversationMetadata? conversation,
|
|
)?
|
|
$default, {
|
|
required TResult orElse(),
|
|
}) {
|
|
final _that = this;
|
|
switch (_that) {
|
|
case _ChatState() when $default != null:
|
|
return $default(
|
|
_that.messages,
|
|
_that.partialResponse,
|
|
_that.activity,
|
|
_that.busy,
|
|
_that.stopping,
|
|
_that.error,
|
|
_that.conversation,
|
|
);
|
|
case _:
|
|
return orElse();
|
|
}
|
|
}
|
|
|
|
/// A `switch`-like method, using callbacks.
|
|
///
|
|
/// As opposed to `map`, this offers destructuring.
|
|
/// It is equivalent to doing:
|
|
/// ```dart
|
|
/// switch (sealedClass) {
|
|
/// case Subclass(:final field):
|
|
/// return ...;
|
|
/// case Subclass2(:final field2):
|
|
/// return ...;
|
|
/// }
|
|
/// ```
|
|
|
|
@optionalTypeArgs
|
|
TResult when<TResult extends Object?>(
|
|
TResult Function(
|
|
List<ChatMessage> messages,
|
|
String partialResponse,
|
|
AgentChatActivity activity,
|
|
bool busy,
|
|
bool stopping,
|
|
AgentChatError? error,
|
|
ConversationMetadata? conversation,
|
|
)
|
|
$default,
|
|
) {
|
|
final _that = this;
|
|
switch (_that) {
|
|
case _ChatState():
|
|
return $default(
|
|
_that.messages,
|
|
_that.partialResponse,
|
|
_that.activity,
|
|
_that.busy,
|
|
_that.stopping,
|
|
_that.error,
|
|
_that.conversation,
|
|
);
|
|
case _:
|
|
throw StateError('Unexpected subclass');
|
|
}
|
|
}
|
|
|
|
/// A variant of `when` that fallback to returning `null`
|
|
///
|
|
/// It is equivalent to doing:
|
|
/// ```dart
|
|
/// switch (sealedClass) {
|
|
/// case Subclass(:final field):
|
|
/// return ...;
|
|
/// case _:
|
|
/// return null;
|
|
/// }
|
|
/// ```
|
|
|
|
@optionalTypeArgs
|
|
TResult? whenOrNull<TResult extends Object?>(
|
|
TResult? Function(
|
|
List<ChatMessage> messages,
|
|
String partialResponse,
|
|
AgentChatActivity activity,
|
|
bool busy,
|
|
bool stopping,
|
|
AgentChatError? error,
|
|
ConversationMetadata? conversation,
|
|
)?
|
|
$default,
|
|
) {
|
|
final _that = this;
|
|
switch (_that) {
|
|
case _ChatState() when $default != null:
|
|
return $default(
|
|
_that.messages,
|
|
_that.partialResponse,
|
|
_that.activity,
|
|
_that.busy,
|
|
_that.stopping,
|
|
_that.error,
|
|
_that.conversation,
|
|
);
|
|
case _:
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
|
|
/// @nodoc
|
|
|
|
class _ChatState implements ChatState {
|
|
const _ChatState({
|
|
List<ChatMessage> messages = const [],
|
|
this.partialResponse = '',
|
|
this.activity = AgentChatActivity.replying,
|
|
this.busy = false,
|
|
this.stopping = false,
|
|
this.error,
|
|
this.conversation,
|
|
}) : _messages = messages;
|
|
|
|
final List<ChatMessage> _messages;
|
|
@override
|
|
@JsonKey()
|
|
List<ChatMessage> get messages {
|
|
if (_messages is EqualUnmodifiableListView) return _messages;
|
|
// ignore: implicit_dynamic_type
|
|
return EqualUnmodifiableListView(_messages);
|
|
}
|
|
|
|
@override
|
|
@JsonKey()
|
|
final String partialResponse;
|
|
@override
|
|
@JsonKey()
|
|
final AgentChatActivity activity;
|
|
@override
|
|
@JsonKey()
|
|
final bool busy;
|
|
@override
|
|
@JsonKey()
|
|
final bool stopping;
|
|
@override
|
|
final AgentChatError? error;
|
|
@override
|
|
final ConversationMetadata? conversation;
|
|
|
|
/// Create a copy of ChatState
|
|
/// with the given fields replaced by the non-null parameter values.
|
|
@override
|
|
@JsonKey(includeFromJson: false, includeToJson: false)
|
|
@pragma('vm:prefer-inline')
|
|
_$ChatStateCopyWith<_ChatState> get copyWith =>
|
|
__$ChatStateCopyWithImpl<_ChatState>(this, _$identity);
|
|
|
|
@override
|
|
bool operator ==(Object other) {
|
|
return identical(this, other) ||
|
|
(other.runtimeType == runtimeType &&
|
|
other is _ChatState &&
|
|
const DeepCollectionEquality().equals(other.messages, _messages) &&
|
|
(identical(other.partialResponse, partialResponse) ||
|
|
other.partialResponse == partialResponse) &&
|
|
(identical(other.activity, activity) ||
|
|
other.activity == activity) &&
|
|
(identical(other.busy, busy) || other.busy == busy) &&
|
|
(identical(other.stopping, stopping) ||
|
|
other.stopping == stopping) &&
|
|
(identical(other.error, error) || other.error == error) &&
|
|
(identical(other.conversation, conversation) ||
|
|
other.conversation == conversation));
|
|
}
|
|
|
|
@override
|
|
int get hashCode {
|
|
return Object.hash(
|
|
runtimeType,
|
|
const DeepCollectionEquality().hash(_messages),
|
|
partialResponse,
|
|
activity,
|
|
busy,
|
|
stopping,
|
|
error,
|
|
conversation,
|
|
);
|
|
}
|
|
|
|
@override
|
|
String toString() {
|
|
return 'ChatState(messages: $messages, partialResponse: $partialResponse, activity: $activity, busy: $busy, stopping: $stopping, error: $error, conversation: $conversation)';
|
|
}
|
|
}
|
|
|
|
/// @nodoc
|
|
abstract mixin class _$ChatStateCopyWith<$Res>
|
|
implements $ChatStateCopyWith<$Res> {
|
|
factory _$ChatStateCopyWith(
|
|
_ChatState value,
|
|
$Res Function(_ChatState) _then,
|
|
) = __$ChatStateCopyWithImpl;
|
|
@override
|
|
@useResult
|
|
$Res call({
|
|
List<ChatMessage> messages,
|
|
String partialResponse,
|
|
AgentChatActivity activity,
|
|
bool busy,
|
|
bool stopping,
|
|
AgentChatError? error,
|
|
ConversationMetadata? conversation,
|
|
});
|
|
|
|
@override
|
|
$ConversationMetadataCopyWith<$Res>? get conversation;
|
|
}
|
|
|
|
/// @nodoc
|
|
class __$ChatStateCopyWithImpl<$Res> implements _$ChatStateCopyWith<$Res> {
|
|
__$ChatStateCopyWithImpl(this._self, this._then);
|
|
|
|
final _ChatState _self;
|
|
final $Res Function(_ChatState) _then;
|
|
|
|
/// Create a copy of ChatState
|
|
/// with the given fields replaced by the non-null parameter values.
|
|
@override
|
|
@pragma('vm:prefer-inline')
|
|
$Res call({
|
|
Object? messages = null,
|
|
Object? partialResponse = null,
|
|
Object? activity = null,
|
|
Object? busy = null,
|
|
Object? stopping = null,
|
|
Object? error = freezed,
|
|
Object? conversation = freezed,
|
|
}) {
|
|
return _then(
|
|
_ChatState(
|
|
messages: null == messages
|
|
? _self._messages
|
|
: messages // ignore: cast_nullable_to_non_nullable
|
|
as List<ChatMessage>,
|
|
partialResponse: null == partialResponse
|
|
? _self.partialResponse
|
|
: partialResponse // ignore: cast_nullable_to_non_nullable
|
|
as String,
|
|
activity: null == activity
|
|
? _self.activity
|
|
: activity // ignore: cast_nullable_to_non_nullable
|
|
as AgentChatActivity,
|
|
busy: null == busy
|
|
? _self.busy
|
|
: busy // ignore: cast_nullable_to_non_nullable
|
|
as bool,
|
|
stopping: null == stopping
|
|
? _self.stopping
|
|
: stopping // ignore: cast_nullable_to_non_nullable
|
|
as bool,
|
|
error: freezed == error
|
|
? _self.error
|
|
: error // ignore: cast_nullable_to_non_nullable
|
|
as AgentChatError?,
|
|
conversation: freezed == conversation
|
|
? _self.conversation
|
|
: conversation // ignore: cast_nullable_to_non_nullable
|
|
as ConversationMetadata?,
|
|
),
|
|
);
|
|
}
|
|
|
|
/// Create a copy of ChatState
|
|
/// with the given fields replaced by the non-null parameter values.
|
|
@override
|
|
@pragma('vm:prefer-inline')
|
|
$ConversationMetadataCopyWith<$Res>? get conversation {
|
|
if (_self.conversation == null) {
|
|
return null;
|
|
}
|
|
|
|
return $ConversationMetadataCopyWith<$Res>(_self.conversation!, (value) {
|
|
return _then(_self.copyWith(conversation: value));
|
|
});
|
|
}
|
|
}
|