migrate Content classes to primary constructors
The Riverpod bug preventing us from doing this has been fixed.
This commit is contained in:
parent
853116ab2f
commit
dd01ad9d74
1 changed files with 120 additions and 162 deletions
|
|
@ -6,14 +6,12 @@ part "image_pack.freezed.dart";
|
|||
part "image_pack.g.dart";
|
||||
|
||||
/// An image pack (MSC2545), from a room's state.
|
||||
@freezed
|
||||
sealed class ImagePackContent extends Content with _$ImagePackContent {
|
||||
ImagePackContent._();
|
||||
factory ImagePackContent({
|
||||
@Default(IMap.empty()) IMap<String, PackImage> images,
|
||||
PackInfo? pack,
|
||||
}) = _ImagePackContent;
|
||||
|
||||
@Freezed(toJson: false, fromJson: false)
|
||||
@JsonSerializable()
|
||||
class const ImagePackContent({
|
||||
final IMap<String, PackImage> images = const .empty(),
|
||||
final PackInfo? pack,
|
||||
}) extends Content with _$ImagePackContent {
|
||||
IMap<String, PackImage> imagesFor(ImageUsage usage) => images.where(
|
||||
(_, image) => switch ((image.usage, pack?.usage ?? const .empty())) {
|
||||
(final usages, _) when usages.isNotEmpty => usages.contains(usage),
|
||||
|
|
|
|||
Loading…
Reference in a new issue