🐛 Fix local db old data cause crash

This commit is contained in:
2024-08-19 09:19:29 +08:00
parent 7ea18dbe12
commit 0006a94632
5 changed files with 28 additions and 8 deletions

View File

@ -72,6 +72,7 @@ class _AttachmentListState extends State<AttachmentList> {
double? consistentValue;
int portrait = 0, square = 0, landscape = 0;
for (var entry in _attachmentsMeta) {
if (entry == null) continue;
if (entry!.metadata?['ratio'] != null) {
if (entry.metadata?['ratio'] is int) {
consistentValue ??= entry.metadata?['ratio'].toDouble();

View File

@ -39,7 +39,7 @@ class ChatEvent extends StatelessWidget {
Widget _buildAttachment(BuildContext context, {bool isMinimal = false}) {
final attachments = item.body['attachments'] != null
? List<String>.from(item.body['attachments'].map((x) => x))
? List<String>.from(item.body['attachments']?.whereType<String>())
: List<String>.empty();
if (attachments.isEmpty) return const SizedBox();

View File

@ -293,7 +293,7 @@ class _PostItemState extends State<PostItem> {
@override
Widget build(BuildContext context) {
final List<String> attachments = item.body['attachments'] is List
? item.body['attachments']?.cast<String>()
? List.from(item.body['attachments']?.whereType<String>())
: List.empty();
final hasAttachment = attachments.isNotEmpty;