redressTextAndAttachment method
Implementation
List<dynamic> redressTextAndAttachment(
String text, int atLen, String atXX, String mimeType, String Cid) {
var spicedCid = '';
//0 image,1 video,2 audio
bool isAudio = false;
bool isVideo = false;
bool isJpeg = false;
bool isPng = false;
bool isGif = false;
bool isImage = false;
//var mty = await lookupMimeType('', headerBytes: attachement);
int atType = 0;
switch (mimeType) {
case 'image/jpeg':
isJpeg = true;
isImage = true;
break;
case 'image/png':
isPng = true;
isImage = true;
break;
case 'image/gif':
isGif = true;
isImage = true;
break;
case 'video/mp4':
isVideo = true;
atType = 1;
break;
case 'audio/mpeg':
isAudio = true;
atType = 2;
break;
}
if (mimeType.startsWith('video')) {
isVideo = true;
atType = 1;
}
if (mimeType.startsWith('audio')) {
isAudio = true;
atType = 2;
}
if (!isImage && !isAudio && !isVideo) {
return [];
}
if (Cid.isEmpty) {
if (atType == 0) spicedCid = ' !&*';
if (atType == 1) spicedCid = ' !∞*';
if (atType == 2) spicedCid = ' !£*';
} else {
if (atType == 0) spicedCid = ' !&' + Cid;
if (atType == 1) spicedCid = ' !∞' + Cid;
if (atType == 2) spicedCid = ' !£' + Cid;
}
final ModeratorCapsuleItemAttachment att =
ModeratorCapsuleItemAttachment(atLen, atXX, Cid);
return [text + spicedCid, att.binary];
}