DeKekem
DeKekem

Reputation: 1753

Localization in Workmanager flutter

I am using the Workmanager plugin to run a task at the defined interval. So far it is working ok although sometimes at will get notifications with failure (when in debug mode) with any exception on the console. But my big concern is how to get the locale within the Workmanager.

@pragma('vm:entry-point')
Future<void> callbackDispatcher() async {
  Workmanager().executeTask((task, inputData) async {
    if (WorkManagerSettings.myTaskKey == task) {
      try {
        await _showNotification();
      } catch (err) {
        debugPrint("error: $err");
        debugPrintStack(); // Logger flutter package, prints error on the debug console
        throw Exception(err);
      }
    }
return Future.value(true);
  });
}

My app is available in 2 languages and the notification has to be in the correct language.

Upvotes: 0

Views: 98

Answers (0)

Related Questions