Skip to content

Instantly share code, notes, and snippets.

@jesusrp98
Created April 16, 2019 19:07
Show Gist options
  • Save jesusrp98/e2a94416119ef2e89b25a94c61874bf6 to your computer and use it in GitHub Desktop.
Save jesusrp98/e2a94416119ef2e89b25a94c61874bf6 to your computer and use it in GitHub Desktop.
Function that actually schedules a notification
Future _scheduleNotification({
BuildContext context,
int id,
String time,
Duration subtract,
}) async {
await ScopedModel.of<AppModel>(context).notifications.schedule(
id,
FlutterI18n.translate(context, 'spacex.notifications.launches.title'),
FlutterI18n.translate(
context,
'spacex.notifications.launches.body',
{
'rocket': launch.rocket.name,
'payload': launch.rocket.secondStage.getPayload(0).id,
'orbit': launch.rocket.secondStage.getPayload(0).orbit,
'time': time,
},
),
launch.launchDate.subtract(subtract),
NotificationDetails(
AndroidNotificationDetails(
'channel.launches',
FlutterI18n.translate(
context,
'spacex.notifications.channel.launches.title',
),
FlutterI18n.translate(
context,
'spacex.notifications.channel.launches.description',
),
importance: Importance.High,
color: Theme.of(context).primaryColor,
),
IOSNotificationDetails(),
),
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment