Answers for "How to cache videos in flutter"

0

How to cache videos in flutter

static var httpClient = new HttpClient();
Future<File> _downloadFile(String url, String filename) async {
  var request = await httpClient.getUrl(Uri.parse(url));
  var response = await request.close();
  var bytes = await consolidateHttpClientResponseBytes(response);
  String dir = (await getApplicationDocumentsDirectory()).path;
  File file = new File('$dir/$filename');
  await file.writeAsBytes(bytes);
  return file;
}
Posted by: Guest on June-12-2021

Code answers related to "How to cache videos in flutter"

Browse Popular Code Answers by Language