solved detached ArrayBuffer error, by cloning the data every time before use

This commit is contained in:
Juan Marulanda De Los Rios 2025-04-24 01:20:46 -04:00
parent ef9cb5b00d
commit 8ae776c92f

View File

@ -1,3 +1,5 @@
import "dart:typed_data";
import "package:crab_ui/structs.dart";
import "package:flutter/material.dart";
import 'package:pdfrx/pdfrx.dart';
@ -14,7 +16,16 @@ class AttachmentWidget extends StatelessWidget {
if (extension == "jpg") {
return Image.memory(att.data);
} else if (extension == "pdf") {
return PdfViewer.data(att.data, sourceName: att.name);
PdfViewer pdf = PdfViewer.data(
Uint8List.fromList(att.data),
sourceName: att.name,
params: const PdfViewerParams(
enableTextSelection: true,
scrollByMouseWheel: 0.5,
)
);
return pdf;
}
return Text(
"Attachment not supported for preview, you'll need to download",
@ -39,19 +50,17 @@ class AttachmentWidget extends StatelessWidget {
CloseButton(onPressed: () => {Navigator.pop(context)}),
Text(
attachment.name
.toString(), //its alr a string but incase ¯\()/¯
.toString(), //its alr a string but incase ¯\()/¯ //update: i did that everywhere lol
style: TextStyle(
color: Colors.black,
fontSize: 20,
decoration:
TextDecoration.none), //TODO: personalize your fonts
decoration: TextDecoration
.none), //TODO: personalize your fonts
),
],
),
Expanded(
child: attachmentViewer(attachment),
child: attachmentViewer(attachment),
)
],
),