Flutter web get file from Uint8List bytes missing extension type at offset 11

Viewed 485

Unable to convert bytes to File in Flutter web

var req = await http.get(uri, headers: headers);
var bytes = req.bodyBytes;
if (UniversalPlatform.isWeb) {
  try {
     uio.File file = uio.File.fromRawPath(bytes);
     return file;
  } catch (ex) {
    print(ex);
  }
}

When I try to convert using universal IO package,Im getting Missing extension byte at 11.Please provide solution to convert uint8list byte to file or please provide solution to download file for flutter web using http client.

1 Answers

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