You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

24 lines
621 B

import 'package:flutter/services.dart';
class LocationService {
static final LocationService _instance = LocationService._internal();
/// 获取单例
factory LocationService() => _instance;
// 方法通道
final MethodChannel _methodChannel = MethodChannel(
'com.yunqiinnovation.location_service',
);
// 内部构造函数
LocationService._internal() {}
Future<Map<String, double>> location() async {
final result = await _methodChannel.invokeMethod<Map>('location');
return {
'latitude': result?['longitude'] ?? 0.0,
'longitude': result?['longitude'] ?? 0.0,
};
}
}