I have a problem, I can't figure out how to convert. I have an entity (for a block). In the entity, I have a variable where I store a pdf file in base64 format. I want to convert a string (from base 64) into a PDF and display this PDF in a modal window. If someone has done this, I will be grateful for help. My goal is to convert base 64, which is in pdfBase, into a file, in order to display this pdf file in the widget
I just want to say the file (but it is not necessary to save it).
My entity
import 'dart:convert';
import 'dart:typed_data';
import 'package:freezed_annotation/freezed_annotation.dart';
part 'warranty_pdf_entity.freezed.dart';
@freezed
class WarrantyPdfEntity with _$WarrantyPdfEntity {
const WarrantyPdfEntity._();
const factory WarrantyPdfEntity({
@Default('') String? pdfBase,
final dynamic filePdf,
}) = _WarrantyPdfEntity;
PdfImage copyWithSelected() {
var pdfDataBytes = base64.decode(pdfgarranty!);
var img = decodeImage(pdfDataBytes);
PdfImage image = PdfImage(
pdf,
image: img!.data.buffer.asUint8List(),
width: img.width,
height: img.height);
return image;
}
}