Mohamed Gamal Mohamed
Mohamed Gamal Mohamed

Reputation: 103

Choosing local storage to store music files in flutter

I want to create a flutter application that allows the user to provide a YouTube video link and download music file of this video and save it in local storage, then in future he can open the music file from local storage, the app also can track the progress, so the user in the next time when he opens the app and open specific music it starts from the last minute he listened for last time.

I don't know which local storage package can I use for storing the music files, and also to store progress data.

Upvotes: 1

Views: 966

Answers (1)

samUser1
samUser1

Reputation: 498

You should definitely use path_provider package.

Here's just a demonstrative example:

Future<dynamic> downloadFile(String url) async {
  String dir = (await getApplicationDocumentsDirectory()).path;
  File file = new File('$dir/$filename');
  var bytes = await getBytesFromLinkYoutube(url);
  await file.writeAsBytes(bytes);
  print(file.path);
}

Future getBytesFromLinkYoutube(String url) {
  //...
}

Upvotes: 2

Related Questions