问题描述
我想传递电池和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 (将#修改为@)