-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
13 changed files
with
167 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
import 'dart:io'; | ||
import 'package:fluttertoast/fluttertoast.dart'; | ||
import 'package:path_provider/path_provider.dart'; | ||
import 'package:http/http.dart' as http; | ||
import 'package:permission_handler/permission_handler.dart'; | ||
|
||
class DownloadSongRepo { | ||
static Future<void> downloadSong({ | ||
required String downloadUrl, | ||
required String fileName, | ||
}) async { | ||
try { | ||
|
||
if (await Permission.storage.request().isGranted) { | ||
|
||
Directory? directory = await getExternalStorageDirectory(); | ||
String downloadPath = "${directory!.path}/Musiq/"; | ||
|
||
Directory(downloadPath).createSync(recursive: true); | ||
|
||
final response = await http.get(Uri.parse(downloadUrl)); | ||
if (response.statusCode == 200) { | ||
String filePath = '$downloadPath$fileName'; | ||
|
||
File file = File(filePath); | ||
await file.writeAsBytes(response.bodyBytes); | ||
Fluttertoast.showToast(msg: "Download complete: $filePath"); | ||
print("Download complete: $filePath"); | ||
} else { | ||
print("Failed to download. Status code: ${response.statusCode}"); | ||
Fluttertoast.showToast( | ||
msg: "Failed to download. Status code: ${response.statusCode}"); | ||
} | ||
} else { | ||
print("Storage permission denied."); | ||
Fluttertoast.showToast(msg: "Storage permission denied."); | ||
} | ||
} catch (e) { | ||
print("Error downloading song: $e"); | ||
Fluttertoast.showToast(msg: "Error downloading song: $e"); | ||
} | ||
} | ||
} |
File renamed without changes.
32 changes: 32 additions & 0 deletions
32
lib/presentation/screens/LibraryScreen/downloadList/download_list.dart
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import 'package:flutter/material.dart'; | ||
import 'package:musiq/presentation/commanWidgets/empty_screen.dart'; | ||
|
||
class DownloadList extends StatelessWidget { | ||
const DownloadList({super.key}); | ||
|
||
@override | ||
Widget build(BuildContext context) { | ||
return Scaffold( | ||
appBar: AppBar( | ||
automaticallyImplyLeading: false, | ||
leading: IconButton( | ||
onPressed: () { | ||
Navigator.pop(context); | ||
}, | ||
icon: Icon( | ||
Icons.arrow_back_ios_new_sharp, | ||
), | ||
), | ||
), | ||
body: emptyScreen( | ||
context: context, | ||
text1: "show", | ||
size1: 15, | ||
text2: "Nothing", | ||
size2: 20, | ||
text3: "Downloads", | ||
size3: 20, | ||
), | ||
); | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters