getThumbnailUsingHerokuapp static method

Future<Uint8List> getThumbnailUsingHerokuapp(
  1. String videoUrl
)

Implementation

static Future<Uint8List> getThumbnailUsingHerokuapp(String videoUrl) async {
  var input = '{"videoUrl" : "$videoUrl"}';
  var url =
      'https://video-thumbnail-generator-pub.herokuapp.com/generate/thumbnail';
  try {
    var response = await http.post(
      Uri.parse(url),
      headers: {'Content-type': 'application/json'},
      body: input,
    );
    if (response.statusCode == 200) {
      var data = response.body;
      return base64Decode(data);
    } else {
      throw 'Could not fetch data from api | Error Code: ${response.statusCode}';
    }
  } on Exception catch (e) {
    throw 'Error : $e';
  }
}