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.
60 lines
1.5 KiB
60 lines
1.5 KiB
import 'package:flutter/services.dart';
|
|
|
|
class AmapService {
|
|
static final AmapService _instance = AmapService._internal();
|
|
|
|
/// 获取单例
|
|
factory AmapService() => _instance;
|
|
|
|
// 方法通道
|
|
final MethodChannel _methodChannel = const MethodChannel(
|
|
'com.yunqiinnovation.amap_service',
|
|
);
|
|
|
|
// 事件通道 - 简化为只使用数据和状态通道
|
|
late final EventChannel _dataEventChannel;
|
|
late final EventChannel _statusEventChannel;
|
|
|
|
// 事件流
|
|
late final Stream<dynamic> _dataStream;
|
|
late final Stream<dynamic> _statusStream;
|
|
|
|
// 获取事件流
|
|
Stream<dynamic> get onDataReceived => _dataStream;
|
|
|
|
// 状态流直接传递原始数据
|
|
Stream<dynamic> get onStatusUpdated => _statusStream;
|
|
|
|
// 内部构造函数
|
|
AmapService._internal() {
|
|
_dataEventChannel = const EventChannel(
|
|
'com.yunqiinnovation.amap_service/data_events',
|
|
);
|
|
_statusEventChannel = const EventChannel(
|
|
'com.yunqiinnovation.amap_service/status_events',
|
|
);
|
|
|
|
// 初始化事件流
|
|
_dataStream = _dataEventChannel.receiveBroadcastStream();
|
|
_statusStream = _statusEventChannel.receiveBroadcastStream();
|
|
}
|
|
// 初始化SDK
|
|
Future<void> initSdk({String? iosKey, String? androidKey}) async {}
|
|
|
|
// 定位初始化
|
|
Future<void> initLocation() async {}
|
|
|
|
// 开始定位
|
|
Future<void> startLocation() async {}
|
|
|
|
// 监听定位返回位置
|
|
Stream<dynamic> locationStream() {
|
|
return _dataStream;
|
|
}
|
|
|
|
// 停止定位
|
|
Future<void> stopLocation() async {}
|
|
|
|
// 销毁
|
|
Future<void> dispose() async {}
|
|
}
|
|
|