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
Flutter Web How to Convert Uint8List to File
Asked Answered
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);
isnt dart : io not supported on flutter-web? –
Middle
Yes, you are right.
dart:io
isn't avalibe on web, but you can use the universal_io
package. –
Tholos ah thankyou i dont know that package exist, will accept your answer after i tried it –
Middle
Okay, here is the package on pub: pub.dev/packages/universal_io –
Tholos
For 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. –
Popham This is not the answer, this uses the Uint8List as the file path, not the actual contents –
Unscrupulous
Error: FormatException: Missing extension byte (at offset 402) Any solution? –
Privileged
© 2022 - 2024 — McMap. All rights reserved.