Flutter Downloader - How to Add Downloading Feature in Flutter App

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hi guys so in this tutorial we are going to learn how to implement downloading option in flutter so let's get started so here I have created a new flutter project in my Android Studio IDE and named it as flutter downloading example and I have removed the default code that is the counter code and simply added a elevated button at the center of my screen okay so let's get started so to implement downloading option in flutter we are going to make use of a library or a package called as flutter media downloader so just go to pop specification. yl file and under dependency section we need to add that so just add flutter mediacore downloader okay so just add this package and hit the PG button so that this package will get installed in your flutter project as a external library now this package need some permissions like internet access for downloading the data and storing it into the devices memory we need storage permission so we need to enable that so just go to Android folder app sources m in here you will get the file called as Android manifest so just open this file and in this manifest tag over here you must add use permissions uses permission one is write external storage so that the downloaded file get down uh stored into the devices and another is internet access so internet access we need to add and then another we need is uh read external storage SP okay so just convert it into to read over here and here we also need to show a notification that the data was downloaded into the devices so we need notification permission so just add okay so these are the four permissions that are required for this dependency to work perfectly okay so just add that in Android folder okay so now let's start the coding thing so once we have implemented or added this file we just need to use it so import download flutter down media downloader do do okay so as this uh package will communicate with the native code we must enable the wigets for that so here wiet binding we need to do Ure initialize okay and we must make this main function as a synchronization okay so before uh running our FL application we must enable this so that our FL this download manager code will be able to communicate with the native code okay so just add that thing and now here in this stateful wiget over here we must create an instance of this so we can just do it like final undor fct download I can name it as equal to Media download okay and now by making use of this instance we can just implement it over here so now this function will make use of uh Internet calls and get the down data downloaded from the internet we must make this function as a synchronization okay so this is on press function so just make this function as a sync letter download do download Media here we must pass context and the URL from which you want to download the data so what I will do is I will just get the data from the internet uh like some PDF file or other thing okay so let's check if I get any tutorial PDF or other thing okay so let's check if this works or no I will just copy this URL and paste it over here okay so now when I press on the button it should work so first of all let me stop this application fully okay so the app got installed again and let me check show you the notification so this is I'll just clear it so when I press on this button it should work it should download the data from the internet and it should show a notification so let's wait it may depend on the file size so it is showing that PDF download was successful okay and it got stored over here so it did not show the notification so let's open a file and let's check okay so you can see it has downloaded it so you can see I have just made use of that URL but it did not show the notification so let me check why so the notification is off this application do not send notification okay I have just set the permission but I don't know why it is not showing the notifications yeah so over here it is notifications s s was missing so that is the reason it was not showing it so I will just install it uninstall it again okay reinstall it again now okay so now when I press on this button so let's check it so it is showing me the to allow the permission for notification so I just allow it okay so you can see I got the notifications over here so it is just downloading it okay so that's all for this video tutorial thanks for watching please do subscribe protoc Cod point thank you
Info
Channel: Proto Coders Point
Views: 1,061
Rating: undefined out of 5
Keywords: flutter, flutter tutorial, android, android tutorial, flutter media download, flutter download, how to add download feature in flutter, flutter_media_downloader, flutter_downloader example, flutter_downloader, How to integrate downloading feature in flutter, downloading files in flutter, flutter download file, flutter download file from url, flutter developers
Id: tRdU5gnbrmc
Channel Id: undefined
Length: 5min 36sec (336 seconds)
Published: Thu Jan 25 2024
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.