Flutter Web How to Convert Uint8List to File
3,062
Since dart:io
isn't avalible on web, you can use the universal_io
package.
Add it to your pubspec.yaml
.
import 'package:universal_io/io.dart';
File createFileFromBytes(Uint8List bytes) => File.fromRawPath(bytes);
Author by
Jolzal
Updated on December 29, 2022Comments
-
Jolzal about 1 year
I am having trouble on converting Uint8List image to File on flutter web since dart:io is not supported on the web, i need it to be file in order to upload it to FirebaseStorage, is there any workaround for this ? thankyou
-
Jolzal almost 3 yearsisnt dart : io not supported on flutter-web?
-
Andrej almost 3 yearsYes, you are right.
dart:io
isn't avalibe on web, but you can use theuniversal_io
package. -
Jolzal almost 3 yearsah thankyou i dont know that package exist, will accept your answer after i tried it
-
Andrej almost 3 yearsOkay, here is the package on pub: pub.dev/packages/universal_io
-
Jeff Frazier about 2 yearsFor me, this returns
Error: FormatException: Unexpected extension byte (at offset 0)
. There are several similar issues reported and the author has yet to reply to any of them. -
PixelToast almost 2 yearsThis is not the answer, this uses the Uint8List as the file path, not the actual contents