dart_pdf
dart_pdf copied to clipboard
The argument type 'Uint8List' can't be assigned to the parameter type 'File'
[The argument type 'Uint8List' can't be assigned to the parameter type 'File'.dartargument_type_not_assignable Uint8List? bytes Type: Uint8List?]
Image - (https://i.stack.imgur.com/iSbTP.png)
My Code:
IconButton(
onPressed: () async {
Uint8List? bytes = await screenshotController.capture();
imageProvider.changeImage(bytes!);
if (!mounted) return;
Navigator.of(context).pop();
},
icon: const Icon(Icons.done),
)
Can someone suggest how to solve this error please? I am a beginner
I tried to pass bytes as parameter with null check, but this isn't working
https://www.youtube.com/watch?v=qXU5o8v4DX0&ab_channel=KODDev
I was coding after which this yt video. It seems to be working for him (Time stamp - 52:25), but not for me.
@Hxrsha-x what you want to do is write the uint8list bytes to a file, to do this you need to create a file first and then write to it.
final bytes = await screenshotController.capture();
final temp = await getTemporaryDirectory();
final file = File('${temp.path}/example.png'); // I assume you're trying to get an image
await file.writeAsBytes(bytes!);
imageProvider.changeImage(file);
@Hxrsha-x what you want to do is write the uint8list bytes to a file, to do this you need to create a file first and then write to it.
final bytes = await screenshotController.capture(); final temp = await getTemporaryDirectory(); final file = File('${temp.path}/example.png'); // I assume you're trying to get an image await file.writeAsBytes(bytes!); imageProvider.changeImage(file);
@Hxrsha-x have you tried this? Does the issue still persist?