Flutter Web How to Convert Uint8List to File

9.2k Views Asked by At

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

1

There are 1 best solutions below

7
On

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);