【发布时间】:2020-12-28 08:29:10
【问题描述】:
我在颤振中开发了一个应用程序来捕获坐标。下面的代码正在正确捕获坐标,但问题是,当应用程序关闭时它不起作用。即使应用程序关闭,我也需要捕获位置。任何帮助将不胜感激
@override
void initState()
{
super.initState( );
BackgroundLocation.startLocationService( );
BackgroundLocation.getLocationUpdates( (location) async {
setState( () {
debugPrint(globals.sUserCode);
debugPrint(globals.sActiveTripCode);
this.latitude = location.latitude.toString( );
this.longitude = location.longitude.toString( );
this.accuracy = location.accuracy.toString( );
this.altitude = location.altitude.toString( );
this.bearing = location.bearing.toString( );
this.speed = location.speed.toString( );
this.time =
DateTime.fromMillisecondsSinceEpoch( location.time.toInt( ) )
.toString( );
} );
}
【问题讨论】:
标签: flutter dart geolocation latitude-longitude