A basic clock app, with all the main features like alarms,stopwatch and clock as available natively in a smartphone.
The clock app in our phone is a very interesting one, it has alarms, stopwatch ,timmer,clock (obiously 😀).Implementing them togerther was fun ,and here are the results that I came forward with.
The alarm clock which can be used obiously to create alarms.This sub app consists of 2 parts creating an
-
Show Alarms The alarms will be shown here with a option to turn off the alrms
-
Creating Alarms Now we will create an alarm , An alarm can have 4 arguments, The argumets are self
explanitory.- Daily or Once
- Alarm Label Notification Title
- Vibrate
- Delete after turned off
-
Alarms For the alarms we take help of which gives us the ability to run
Isolatesin background, and paired up withflutter_local_notificationsandflutter_vibratehelps to create a perfect alarm.
android_alarm_manager_plus: ^2.0.5
flutter_local_notifications: ^9.7.0
flutter_vibrate: ^1.3.0As it's the most difficult topic in this project, so it's good to share some snippets
One shot Alarm
This alarm will be assigned only once in the given DateTime dateTime await AndroidAlarmManager.oneShotAt(
datetime,
alarm_id,
(){
// A function inplementing the background call
},
alarmClock: true,
wakeup: true,
exact: true);Periodic Alarms
This alarm will be assigned periodically DateTime dateTime await AndroidAlarmManager.periodic(
const Duration(days: 1), // periodic range
0, // alarmID
(){
// A function implementing the background call
},
startAt: dateTime, // After what time to start the periodic call
wakeup: true,
exact: true,
);There is no clock app without a clock itself 😆. Thus I made a simple analog clock, which shows the current time. Simple right. But the cache is 🤟you can add multiple timezones which shows there's time.
Timezone The timezone data is being taken from http://worldtimeapi.org/
Schema for the api
curl "http://worldtimeapi.org/api/timezone/Asia/Kolkata"{
"abbreviation": "IST",
"client_ip": "202.78.234.207",
"datetime": "2022-10-01T23:42:19.812452+05:30",
"day_of_week": 6,
"day_of_year": 274,
"dst": false,
"dst_from": null,
"dst_offset": 0,
"dst_until": null,
"raw_offset": 19800,
"timezone": "Asia/Kolkata",
"unixtime": 1664647939,
"utc_datetime": "2022-10-01T18:12:19.812452+00:00",
"utc_offset": "+05:30",
"week_number": 39
}The timezone data is then cached to the localstorage with hive.So that there is just a single api call , then the data can be loaded from the database.
This sub app is a simple stopwatch with the functionality to create laps.
To contribute to this project follow the instructions
git clone https://github.com/tuuhin/clockwork
cd clockworkAdding dependencies
flutter pub get
flutter pub run build_runner buildRun the project
flutter runIts a basic all in one clock app , the stopwatch and clock works well , there is some bugs associated with it, mainly the the alarm clock part but I am ending the project here, as it meets most of the requirements of a clock app





