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