add Emoji.data, passed back to onSelection

This commit is contained in:
Henry Hiles 2026-10-23 17:13:06 -04:00
commit cc814857d5
Signed by: Henry-Hiles
SSH key fingerprint: SHA256:VKQUdS31Q90KvX7EkKMHMBpUspcmItAh86a+v7PGiIs
2 changed files with 26 additions and 19 deletions

View file

@ -16,6 +16,10 @@ class Emoji({
required final IList<String> aliases,
required final String description,
required final IList<String> tags,
/// Anything else the app needs about a custom emoji, e.g. the image it came
/// from, passed back as is to `onSelection`.
@JsonKey(includeFromJson: false) final Object? data,
}) with _$Emoji {
static Widget widgetFromJson(String emoji) => Text(emoji);

View file

@ -27,20 +27,20 @@ $EmojiCopyWith<Emoji> get copyWith => _$EmojiCopyWithImpl<Emoji>(this as Emoji,
@override
bool operator ==(Object other) {
final _this = this as Emoji;
return identical(this, other) || (other.runtimeType == runtimeType&&other is Emoji&&(identical(other.widget, _this.widget) || other.widget == _this.widget)&&(identical(other.value, _this.value) || other.value == _this.value)&&const DeepCollectionEquality().equals(other.aliases, _this.aliases)&&(identical(other.description, _this.description) || other.description == _this.description)&&const DeepCollectionEquality().equals(other.tags, _this.tags));
return identical(this, other) || (other.runtimeType == runtimeType&&other is Emoji&&(identical(other.widget, _this.widget) || other.widget == _this.widget)&&(identical(other.value, _this.value) || other.value == _this.value)&&const DeepCollectionEquality().equals(other.aliases, _this.aliases)&&(identical(other.description, _this.description) || other.description == _this.description)&&const DeepCollectionEquality().equals(other.tags, _this.tags)&&const DeepCollectionEquality().equals(other.data, _this.data));
}
@override
int get hashCode {
final _this = this as Emoji;
return Object.hash(runtimeType,_this.widget,_this.value,const DeepCollectionEquality().hash(_this.aliases),_this.description,const DeepCollectionEquality().hash(_this.tags));
return Object.hash(runtimeType,_this.widget,_this.value,const DeepCollectionEquality().hash(_this.aliases),_this.description,const DeepCollectionEquality().hash(_this.tags),const DeepCollectionEquality().hash(_this.data));
}
@override
String toString() {
final _this = this as Emoji;
return 'Emoji(widget: ${_this.widget}, value: ${_this.value}, aliases: ${_this.aliases}, description: ${_this.description}, tags: ${_this.tags})';
return 'Emoji(widget: ${_this.widget}, value: ${_this.value}, aliases: ${_this.aliases}, description: ${_this.description}, tags: ${_this.tags}, data: ${_this.data})';
}
@ -51,7 +51,7 @@ abstract mixin class $EmojiCopyWith<$Res> {
factory $EmojiCopyWith(Emoji value, $Res Function(Emoji) _then) = _$EmojiCopyWithImpl;
@useResult
$Res call({
@JsonKey(fromJson: Emoji.widgetFromJson, readValue: Emoji.readWidgetValueFromJson) Widget widget,@JsonKey(name: "emoji") String value, IList<String> aliases, String description, IList<String> tags
@JsonKey(fromJson: Emoji.widgetFromJson, readValue: Emoji.readWidgetValueFromJson) Widget widget,@JsonKey(name: "emoji") String value, IList<String> aliases, String description, IList<String> tags,@JsonKey(includeFromJson: false) Object? data
});
@ -68,14 +68,14 @@ class _$EmojiCopyWithImpl<$Res>
/// Create a copy of Emoji
/// with the given fields replaced by the non-null parameter values.
@pragma('vm:prefer-inline') @override $Res call({Object? widget = null,Object? value = null,Object? aliases = null,Object? description = null,Object? tags = null,}) {
@pragma('vm:prefer-inline') @override $Res call({Object? widget = null,Object? value = null,Object? aliases = null,Object? description = null,Object? tags = null,Object? data = freezed,}) {
return _then(Emoji(
widget: null == widget ? _self.widget : widget // ignore: cast_nullable_to_non_nullable
as Widget,value: null == value ? _self.value : value // ignore: cast_nullable_to_non_nullable
as String,aliases: null == aliases ? _self.aliases : aliases // ignore: cast_nullable_to_non_nullable
as IList<String>,description: null == description ? _self.description : description // ignore: cast_nullable_to_non_nullable
as String,tags: null == tags ? _self.tags : tags // ignore: cast_nullable_to_non_nullable
as IList<String>,
as IList<String>,data: freezed == data ? _self.data : data ,
));
}
@ -160,10 +160,10 @@ return $default(_that);case _:
/// }
/// ```
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function(@JsonKey(fromJson: Emoji.widgetFromJson, readValue: Emoji.readWidgetValueFromJson) Widget widget, @JsonKey(name: "emoji") String value, IList<String> aliases, String description, IList<String> tags)? $default,{required TResult orElse(),}) {final _that = this;
@optionalTypeArgs TResult maybeWhen<TResult extends Object?>(TResult Function(@JsonKey(fromJson: Emoji.widgetFromJson, readValue: Emoji.readWidgetValueFromJson) Widget widget, @JsonKey(name: "emoji") String value, IList<String> aliases, String description, IList<String> tags, @JsonKey(includeFromJson: false) Object? data)? $default,{required TResult orElse(),}) {final _that = this;
switch (_that) {
case _Emoji() when $default != null:
return $default(_that.widget,_that.value,_that.aliases,_that.description,_that.tags);case _:
return $default(_that.widget,_that.value,_that.aliases,_that.description,_that.tags,_that.data);case _:
return orElse();
}
@ -181,10 +181,10 @@ return $default(_that.widget,_that.value,_that.aliases,_that.description,_that.t
/// }
/// ```
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function(@JsonKey(fromJson: Emoji.widgetFromJson, readValue: Emoji.readWidgetValueFromJson) Widget widget, @JsonKey(name: "emoji") String value, IList<String> aliases, String description, IList<String> tags) $default,) {final _that = this;
@optionalTypeArgs TResult when<TResult extends Object?>(TResult Function(@JsonKey(fromJson: Emoji.widgetFromJson, readValue: Emoji.readWidgetValueFromJson) Widget widget, @JsonKey(name: "emoji") String value, IList<String> aliases, String description, IList<String> tags, @JsonKey(includeFromJson: false) Object? data) $default,) {final _that = this;
switch (_that) {
case _Emoji():
return $default(_that.widget,_that.value,_that.aliases,_that.description,_that.tags);case _:
return $default(_that.widget,_that.value,_that.aliases,_that.description,_that.tags,_that.data);case _:
throw StateError('Unexpected subclass');
}
@ -201,10 +201,10 @@ return $default(_that.widget,_that.value,_that.aliases,_that.description,_that.t
/// }
/// ```
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function(@JsonKey(fromJson: Emoji.widgetFromJson, readValue: Emoji.readWidgetValueFromJson) Widget widget, @JsonKey(name: "emoji") String value, IList<String> aliases, String description, IList<String> tags)? $default,) {final _that = this;
@optionalTypeArgs TResult? whenOrNull<TResult extends Object?>(TResult? Function(@JsonKey(fromJson: Emoji.widgetFromJson, readValue: Emoji.readWidgetValueFromJson) Widget widget, @JsonKey(name: "emoji") String value, IList<String> aliases, String description, IList<String> tags, @JsonKey(includeFromJson: false) Object? data)? $default,) {final _that = this;
switch (_that) {
case _Emoji() when $default != null:
return $default(_that.widget,_that.value,_that.aliases,_that.description,_that.tags);case _:
return $default(_that.widget,_that.value,_that.aliases,_that.description,_that.tags,_that.data);case _:
return null;
}
@ -216,7 +216,7 @@ return $default(_that.widget,_that.value,_that.aliases,_that.description,_that.t
class _Emoji extends Emoji {
_Emoji({@JsonKey(fromJson: Emoji.widgetFromJson, readValue: Emoji.readWidgetValueFromJson) required this.widget, @JsonKey(name: "emoji") required this.value, required this.aliases, required this.description, required this.tags}): super(widget: widget, value: value, aliases: aliases, description: description, tags: tags);
_Emoji({@JsonKey(fromJson: Emoji.widgetFromJson, readValue: Emoji.readWidgetValueFromJson) required this.widget, @JsonKey(name: "emoji") required this.value, required this.aliases, required this.description, required this.tags, @JsonKey(includeFromJson: false) this.data}): super(widget: widget, value: value, aliases: aliases, description: description, tags: tags, data: data);
@override@JsonKey(fromJson: Emoji.widgetFromJson, readValue: Emoji.readWidgetValueFromJson) final Widget widget;
@ -224,6 +224,9 @@ class _Emoji extends Emoji {
@override final IList<String> aliases;
@override final String description;
@override final IList<String> tags;
/// Anything else the app needs about a custom emoji, e.g. the image it came
/// from, passed back as is to `onSelection`.
@override@JsonKey(includeFromJson: false) final Object? data;
/// Create a copy of Emoji
/// with the given fields replaced by the non-null parameter values.
@ -235,18 +238,18 @@ _$EmojiCopyWith<_Emoji> get copyWith => __$EmojiCopyWithImpl<_Emoji>(this, _$ide
@override
bool operator ==(Object other) {
return identical(this, other) || (other.runtimeType == runtimeType&&other is _Emoji&&(identical(other.widget, widget) || other.widget == widget)&&(identical(other.value, value) || other.value == value)&&const DeepCollectionEquality().equals(other.aliases, aliases)&&(identical(other.description, description) || other.description == description)&&const DeepCollectionEquality().equals(other.tags, tags));
return identical(this, other) || (other.runtimeType == runtimeType&&other is _Emoji&&(identical(other.widget, widget) || other.widget == widget)&&(identical(other.value, value) || other.value == value)&&const DeepCollectionEquality().equals(other.aliases, aliases)&&(identical(other.description, description) || other.description == description)&&const DeepCollectionEquality().equals(other.tags, tags)&&const DeepCollectionEquality().equals(other.data, data));
}
@override
int get hashCode {
return Object.hash(runtimeType,widget,value,const DeepCollectionEquality().hash(aliases),description,const DeepCollectionEquality().hash(tags));
return Object.hash(runtimeType,widget,value,const DeepCollectionEquality().hash(aliases),description,const DeepCollectionEquality().hash(tags),const DeepCollectionEquality().hash(data));
}
@override
String toString() {
return 'Emoji(widget: $widget, value: $value, aliases: $aliases, description: $description, tags: $tags)';
return 'Emoji(widget: $widget, value: $value, aliases: $aliases, description: $description, tags: $tags, data: $data)';
}
@ -257,7 +260,7 @@ abstract mixin class _$EmojiCopyWith<$Res> implements $EmojiCopyWith<$Res> {
factory _$EmojiCopyWith(_Emoji value, $Res Function(_Emoji) _then) = __$EmojiCopyWithImpl;
@override @useResult
$Res call({
@JsonKey(fromJson: Emoji.widgetFromJson, readValue: Emoji.readWidgetValueFromJson) Widget widget,@JsonKey(name: "emoji") String value, IList<String> aliases, String description, IList<String> tags
@JsonKey(fromJson: Emoji.widgetFromJson, readValue: Emoji.readWidgetValueFromJson) Widget widget,@JsonKey(name: "emoji") String value, IList<String> aliases, String description, IList<String> tags,@JsonKey(includeFromJson: false) Object? data
});
@ -274,14 +277,14 @@ class __$EmojiCopyWithImpl<$Res>
/// Create a copy of Emoji
/// with the given fields replaced by the non-null parameter values.
@override @pragma('vm:prefer-inline') $Res call({Object? widget = null,Object? value = null,Object? aliases = null,Object? description = null,Object? tags = null,}) {
@override @pragma('vm:prefer-inline') $Res call({Object? widget = null,Object? value = null,Object? aliases = null,Object? description = null,Object? tags = null,Object? data = freezed,}) {
return _then(_Emoji(
widget: null == widget ? _self.widget : widget // ignore: cast_nullable_to_non_nullable
as Widget,value: null == value ? _self.value : value // ignore: cast_nullable_to_non_nullable
as String,aliases: null == aliases ? _self.aliases : aliases // ignore: cast_nullable_to_non_nullable
as IList<String>,description: null == description ? _self.description : description // ignore: cast_nullable_to_non_nullable
as String,tags: null == tags ? _self.tags : tags // ignore: cast_nullable_to_non_nullable
as IList<String>,
as IList<String>,data: freezed == data ? _self.data : data ,
));
}