timezone stuff for notifcations
This commit is contained in:
parent
86a50e4f85
commit
0b63598ee7
1 changed files with 11 additions and 0 deletions
|
@ -10,6 +10,9 @@ import 'package:flutter_local_notifications/flutter_local_notifications.dart';
|
||||||
import 'package:rxdart/subjects.dart';
|
import 'package:rxdart/subjects.dart';
|
||||||
import 'package:flutter/services.dart';
|
import 'package:flutter/services.dart';
|
||||||
|
|
||||||
|
import 'package:timezone/data/latest.dart' as tz;
|
||||||
|
import 'package:timezone/timezone.dart' as tz;
|
||||||
|
|
||||||
final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
|
final FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
|
||||||
FlutterLocalNotificationsPlugin();
|
FlutterLocalNotificationsPlugin();
|
||||||
|
|
||||||
|
@ -42,6 +45,8 @@ Future<void> main() async {
|
||||||
// Notification stuff
|
// Notification stuff
|
||||||
WidgetsFlutterBinding.ensureInitialized();
|
WidgetsFlutterBinding.ensureInitialized();
|
||||||
|
|
||||||
|
await _configureLocalTimeZone();
|
||||||
|
|
||||||
final NotificationAppLaunchDetails notificationAppLaunchDetails =
|
final NotificationAppLaunchDetails notificationAppLaunchDetails =
|
||||||
await flutterLocalNotificationsPlugin.getNotificationAppLaunchDetails();
|
await flutterLocalNotificationsPlugin.getNotificationAppLaunchDetails();
|
||||||
|
|
||||||
|
@ -83,6 +88,12 @@ Future<void> main() async {
|
||||||
runApp(OhThatsA());
|
runApp(OhThatsA());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Future<void> _configureLocalTimeZone() async {
|
||||||
|
tz.initializeTimeZones();
|
||||||
|
final String timeZoneName = await platform.invokeMethod('getTimeZoneName');
|
||||||
|
tz.setLocalLocation(tz.getLocation(timeZoneName));
|
||||||
|
}
|
||||||
|
|
||||||
class OhThatsA extends StatelessWidget {
|
class OhThatsA extends StatelessWidget {
|
||||||
// This widget is the root of your application.
|
// This widget is the root of your application.
|
||||||
@override
|
@override
|
||||||
|
|
Loading…
Add table
Reference in a new issue