fix: improve type safety in ExternalEmbed parsing

Replace unsafe .cast<Map<String, dynamic>>() with .whereType() to
prevent runtime errors when parsing images array.

The .cast() method throws at runtime if list contains non-Map items.
The .whereType() method safely filters out invalid items.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>

Changed files
+21
lib
models
+21
lib/models/post.dart
···
this.description,
this.thumb,
this.domain,
+
this.embedType,
+
this.provider,
+
this.images,
+
this.totalCount,
});
factory ExternalEmbed.fromJson(Map<String, dynamic> json) {
+
// Thumb is always a string URL (backend transforms blob refs before sending)
+
+
// Handle images array if present
+
List<Map<String, dynamic>>? imagesList;
+
if (json['images'] != null && json['images'] is List) {
+
imagesList =
+
(json['images'] as List).whereType<Map<String, dynamic>>().toList();
+
}
+
return ExternalEmbed(
uri: json['uri'] as String,
title: json['title'] as String?,
description: json['description'] as String?,
thumb: json['thumb'] as String?,
domain: json['domain'] as String?,
+
embedType: json['embedType'] as String?,
+
provider: json['provider'] as String?,
+
images: imagesList,
+
totalCount: json['totalCount'] as int?,
);
}
final String uri;
···
final String? description;
final String? thumb;
final String? domain;
+
final String? embedType;
+
final String? provider;
+
final List<Map<String, dynamic>>? images;
+
final int? totalCount;
}
class PostFacet {