Flutter Cron Job Scheduler - Show local notification at specific time

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys welcome to protocol does point okay so in this photo tutorial we're gonna learn how to job schedule in flutter means uh suppose if you want to run a function at a certain interval of time for example if we say if you want to run a function every second or every one minute or every hour then you can make use of job scheduler so to schedule a job in flutter we will make use of a library called as con okay so let's begin okay so first of all we need to add a dependency in pub specification dot aml file so i'm making use of a same photo project that i have made use in my previous tutorials okay so just open pub specification dot yam as well and under dependency section you can see i have added a library called as con c-o-c-r-o-n call okay so just add this library and hit this pub get button okay so after adding that come to main dot dot page and over here you need to import the library okay so now after importing you can make use of this live package okay so to make use of of con package here in main page the main class over here before starting your actual app okay so over here you need to define or create an object of corn so final con is equal to con okay so like this okay so you can just define it anywhere where you want for example uh if you want to run a con job then you can just define a button to start this con job so i am defining it in my main main page because i want to start this con immediately after this class got loaded okay so over here so i will just make use of con object con schedule schedule dot parse schedule dot parse okay so over here now you need to define some stars so let me explain you what it is so before that here let's create it as a function okay and make this class as a synchronized function as a synchronization okay so over here you can define the job that you want to perform or event that you want to perform so for now i will just print a message on the screen so let me print as every second so here you need to define some stars thus the stars indicates the time at what time this should get run for example here you need to define 5 mandatory stars okay so like this so this starts defines at what time other this function should work okay so let me explain you the first star defines that day of week the second star defines month of a week day of a month hour and minute okay so this documentation is on my website protocolspoint.com so you can read about it the link will be the description okay so now suppose i want to run every one second so this function i want to run every one second so there is the optional star okay so here you need to define some seconds so let's say one second so every one second this function will work okay so let me run this and show you okay so the app is running so you can see every one second the con job okay so now suppose i want to run every minute okay so at that time you can define it over here so i have just removed the second second starts so here if you define as one so this console will work every once minute okay so so if you want to run at a particular minute for example if a user opens the app for the first time forever for five minutes if you want to run this con job okay so you can just define it as something like one two comma 3 comma 4 comma 5 okay so what this will do is this con job will work every 1 minute so after 1 minute 2 minutes so every 1 minute it will work for five minutes so this console will work for five times okay so you can define it something like this or you can just define it like one two five or one to ten so suppose if you want to uh run this con job at a particular day of a month or a week for example if you want to run the con job every sunday so if you want to run this every sunday that time you can define the weak position means the first star okay so this con job will work every sunday okay so if you want to define it as on which month you want to run so you can just define over here so let's say may so this con job will work may month every sunday okay and if you want to define something january or fab feb web you can just define it in short form so on every feb sunday it will this console will work okay and on every sunday may month it will this console will fall okay so now here if you have observed i have also added a awesome notification package to show a local notification in flutter app so i have already made a video tutorial on this uh of how to show local notification in flutter okay so by making use of this package we will show uh notifications to the user by making use of con cellular okay so let's start okay so first of all add this dependency that is awesome notification and hit this pop get button and after that you need to import it okay so i have already created a video tutorial on the same of how to show a notification and i have also wrote an article on that so i will just copy the code from there so you can just visit protocolduspoint.com to get this source code of local notification so i will just copy paste the codes from here so you can see i have made a video tutorial on the same so you can just watch it if you want okay so we have done importing part so you need to initialize it first so i will just copy it and paste it in main dot main page main class okay and the notification code is over here yeah so i will just copy it and every five seconds i want to show this notification so i will just define it as five seconds okay let me run this so wait so every five seconds i want to show this notification to the user okay so this is the title of a notification and this is the body of the notification and this is the key so i have explained everything about this in my notifications video so there is a playlist on that you can just check it out okay so now i will just stop the app and run it again okay so app is getting installed so let's wait okay so let's wait for five seconds for the first notification okay so you saw there is first notification so i'll just turn on the sound okay so let's wait for five seconds so you heard the notification sound so every five seconds the notification will be triggered okay so i'll just stop it okay so showing the notification every five seconds is not a good idea so you just need to customize it for the video sake i have just give as of 5 seconds so you can just define every sunday you want to show this notification to the user for every month as i shown means months i month i have defined over here and also the week day okay like sunday so you can just customize it as per your needs okay so that's all for this video tutorial hope you got the concept of how to push notification uh in water by making use of cons of cellular at a particular interval of time so thanks for watching please do subscribe protocols point thank you you
Info
Channel: Proto Coders Point
Views: 9,038
Rating: undefined out of 5
Keywords: Cron format, Flutter background task, Flutter periodic task, Flutter schedule background task, Flutter schedule task, Notification every hour, Show local notification at specific time, Workmanager Flutter, cron in flutter, cron job, cron job in flutter, cron job scheduler, flutter, flutter cron, flutter cron job, flutter tutorial, flutter tutorial for beginners, how to schedule notification in flutter, notification schedule, schedule notification flutter
Id: iALQnz7FWlE
Channel Id: undefined
Length: 9min 51sec (591 seconds)
Published: Sun Dec 12 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.