如何解决如何从服务类中的其他共享首选项类中获取数据?
我想传递电池和GPS信息或Web服务中的任何其他信息,即使位置被终止,即使位置发生变化,该信息也会始终被调用,但是我无法传递该Web中除LocationDto
以外的其他信息服务,所以请帮助我:
我使用了 background_locator:1.1.13 + 1
以下是服务类内部的方法:
Future<void> callback(LocationDto locationDto) async {
print('$_count location in dart: ${locationDto.toString()}');
await setLogPosition(_count,locationDto);
print('$_count location in dart: ${locationDto.toString()}');
print("___________________________________________");
print("latest_latitude: ${locationDto.latitude}");
print("latest_longitude: ${locationDto.longitude}");
print("___________________________________________");
try {
String url = "http://example.com/App_LatLong";
var jsonData =
'{ "latitude" : ${locationDto.latitude},"longitude" : ${locationDto.longitude} }';
var parsedJson = json.decode(jsonData);
Dio dio = new Dio();
Response response = await dio.post(url,data: parsedJson);
print("api_response_1" + response.toString());
StandardModel homeData = standardModelFromMap(response.toString());
print("api_response" + homeData.toString());
print("success_in_api" );
} on DioError catch (e) {
print("failure_in_api" );
}
final SendPort send = IsolateNameServer.lookupPortByName(isolateName);
send?.send(locationDto);
_count++;
}
}
谢谢
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。