У меня есть приложение, которое работает в фоновом режиме во флаттере ??
Я использовал фоновый обратный вызов в качестве функции для работы в фоновом режиме ...
Мне нужно передать Значение "driver_Id" в этой функции, но я не знаю как.
значение становится из конструктора с другого экрана,
, пожалуйста, помогите мне
это моя функция
static void backgroundCallback(List<LocationData> locations) async {
print('Sample app received data location: $locations');
FlutterLocalNotificationsPlugin flutterLocalNotificationsPlugin =
new FlutterLocalNotificationsPlugin();
var initializationSettingsAndroid =
AndroidInitializationSettings('@mipmap/ic_launcher');
var initializationSettingsIOS = IOSInitializationSettings();
var initializationSettings = InitializationSettings(
initializationSettingsAndroid, initializationSettingsIOS);
flutterLocalNotificationsPlugin.initialize(initializationSettings);
var androidPlatformChannelSpecifics = new AndroidNotificationDetails(
'location_update',
'Location Updates',
'You will receive location updates here',
importance: Importance.Max,
priority: Priority.High);
var iOSPlatformChannelSpecifics = new IOSNotificationDetails();
var platformChannelSpecifics = new NotificationDetails(
androidPlatformChannelSpecifics, iOSPlatformChannelSpecifics);
// await flutterLocalNotificationsPlugin.show(0, 'New Location Received !',
"${locations[0].latitude}, ${locations[0].longitude}", platformChannelSpecifics); // $driver_id
var response = await http.post(URL, headers: {"Content-type": "application/json"}, body:
'{"driver_id":$driver_Id,"Latitude":"${locations[0].latitude}","longitude":"${locations[0].longitude}"}')
;
print (json.decode(response.body)) ;
}