Search code examples
httpflutterdartimageurluint8array

Flutter consolidateHttpClientResponseBytes not defined error?


I'm trying to parse a url image in order to turn it into Uint8 bytes and share across my share provider. When trying to consolidate my http response into bytes I get the following error The method 'consolidateHttpClientResponseBytes' isn't defined by my class. Here is the code I'm trying to use..... Please help!

 Future<Null> shareImage() async{
    var request = await HttpClient().getUrl(Uri.parse('network_image_url'));
    var response = await request.close();
    Uint8List bytes = await consolidateHttpClientResponseBytes(response);
  }

Solution

  • Import this :

    import 'dart:typed_data';
    import 'package:flutter/foundation.dart';
    import 'package:path_provider/path_provider.dart';
    

    And you should be good