Implemented StreamAttachmentPackage and fixed operations in widgets linked to full screen implementation, also fixed tests

This commit is contained in:
Ayush Shekhar
2022-04-13 18:02:49 +05:30
parent 65a5af7b6c
commit 180c24ae72
18 changed files with 373 additions and 253 deletions
@@ -2,6 +2,7 @@ import 'dart:async';
import 'dart:math' as math;
import 'package:flutter/material.dart';
import 'package:stream_chat_flutter/src/stream_attachment_package.dart';
import 'package:stream_chat_flutter/src/extension.dart';
import 'package:stream_chat_flutter/stream_chat_flutter.dart';
import 'package:url_launcher/url_launcher.dart';
@@ -429,3 +430,19 @@ int levenshtein(String s, String t, {bool caseSensitive = true}) {
return v1[t.length];
}
/// An easy way to handle attachment related operations on a message
extension AttachmentPackagesX on Message {
/// This extension will return a List of type [StreamAttachmentPackage] from the
/// existing attachments of the message
List<StreamAttachmentPackage> getAttachmentPackageList() {
final _attachmentPackages = List<StreamAttachmentPackage>.generate(
attachments.length,
(index) => StreamAttachmentPackage(
attachment: attachments[index],
message: this,
),
);
return _attachmentPackages;
}
}