I am using awesome_notification package for pushing notifications through my app. I have almost completed everything but I am stuck right at the edge.
So the thing I want is the code for pickSchedule
.
First I want to pick a weekday:
Secondly I want to set the time:
After selecting the weekday and time I want to push the scheduled notification
on that particular time.
Here is the tutorial video: https://www.youtube.com/watch?v=JAq9fVn3X7U&t=3420s
The code for the particular thing that I want is on time stamp 56:59
of the video.
I could retrieve only this much of the code:
import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';
class NotificationWeekAndTime {
final int dayOfTheWeek;
final TimeOfDay timeOfDay;
NotificationWeekAndTime({
required this.dayOfTheWeek,
required this.timeOfDay,
});
}
Future<NotificationWeekAndTime?> pickSchedule(
BuildContext context,
) async {
List<String> weekdays = [
'Mon',
'Tue',
'Wed',
'Thu',
'Fri',
'Sat',
'Sun',
];
TimeOfDay? timeOfDay;
DateTime now = DateTime.now();
int? selectedDay;
await showDialog(
context: context,
builder: (context) {
return AlertDialog(
title: Text(
'Select day of the week',
style: TextStyle(
fontFamily: GoogleFonts.shadowsIntoLight().fontFamily,
letterSpacing: 1.5,
),
textAlign: TextAlign.center,
),
content: Wrap(
alignment: WrapAlignment.center,
spacing: 3,
children: [
for (int index = 0; index < weekdays.length; index++)
ElevatedButton(
onPressed: () {
selectedDay = index + 1;
Navigator.pop(context);
},
style: ButtonStyle(
backgroundColor:
MaterialStateProperty.all<Color>(Colors.teal),
),
child: Text(
weekdays[index],
style: TextStyle(
color: Colors.white,
fontFamily: GoogleFonts.shadowsIntoLight().fontFamily,
letterSpacing: 1.1,
),
),
),
],
),
);
},
);
}
I need rest of the code to finish my project.