release: 1.0.12
This commit is contained in:
@ -223,7 +223,7 @@ class _MapState extends State<AMapWidget> {
|
||||
@override
|
||||
void deactivate() async {
|
||||
super.deactivate();
|
||||
print('deactivate AMapWidget}');
|
||||
print('deactivate AMapWidget');
|
||||
}
|
||||
|
||||
@override
|
||||
|
@ -1,27 +1,42 @@
|
||||
/// 地图覆盖物基类
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
class BaseOverlay {
|
||||
/// overlay id
|
||||
late String _id;
|
||||
String _id;
|
||||
|
||||
String get id => _id;
|
||||
|
||||
BaseOverlay() {
|
||||
_id = hashCode.toString();
|
||||
// 初始化 _id,在创建对象时唯一确定
|
||||
BaseOverlay() : _id = _generateUniqueId();
|
||||
|
||||
// 设置复制的 ID,确保拷贝对象时的唯一性或保留性
|
||||
void setIdForCopy(String copyId) {
|
||||
if (copyId.isNotEmpty) {
|
||||
_id = copyId;
|
||||
} else {
|
||||
throw ArgumentError('Invalid ID for copy');
|
||||
}
|
||||
}
|
||||
|
||||
void setIdForCopy(String copyId) => _id = copyId;
|
||||
|
||||
// 克隆对象,确保子类正确实现 clone 方法
|
||||
BaseOverlay clone() {
|
||||
throw UnimplementedError(
|
||||
'BaseOverlay subClass should implement this methed.');
|
||||
'BaseOverlay subClass should implement this method.');
|
||||
}
|
||||
|
||||
// 将对象转换为 map 表示
|
||||
Map<String, dynamic> toMap() {
|
||||
throw UnimplementedError(
|
||||
'BaseOverlay subClass should implement this methed.');
|
||||
'BaseOverlay subClass should implement this method.');
|
||||
}
|
||||
|
||||
// 生成唯一 ID 的静态方法
|
||||
static String _generateUniqueId() {
|
||||
return '${DateTime.now().millisecondsSinceEpoch}_${UniqueKey()}';
|
||||
}
|
||||
}
|
||||
|
||||
// 序列化覆盖物集合
|
||||
List<Map<String, dynamic>>? serializeOverlaySet(Set<BaseOverlay> overlays) {
|
||||
return overlays
|
||||
.map<Map<String, dynamic>>((BaseOverlay overlay) => overlay.toMap())
|
||||
|
@ -245,6 +245,17 @@ class Marker extends BaseOverlay {
|
||||
@override
|
||||
int get hashCode => Object.hashAll([
|
||||
id,
|
||||
alpha,
|
||||
anchor,
|
||||
clickable,
|
||||
draggable,
|
||||
icon,
|
||||
infoWindowEnable,
|
||||
infoWindow,
|
||||
position,
|
||||
rotation,
|
||||
visible,
|
||||
zIndex
|
||||
]);
|
||||
}
|
||||
|
||||
|
@ -100,9 +100,8 @@ class Polygon extends BaseOverlay {
|
||||
}
|
||||
|
||||
@override
|
||||
int get hashCode => Object.hashAll([
|
||||
id,
|
||||
]);
|
||||
int get hashCode => Object.hashAll(
|
||||
[id, points, strokeWidth, strokeColor, fillColor, visible, joinType]);
|
||||
|
||||
dynamic _pointsToJson() {
|
||||
final List<dynamic> result = <dynamic>[];
|
||||
|
@ -188,6 +188,15 @@ class Polyline extends BaseOverlay {
|
||||
@override
|
||||
int get hashCode => Object.hashAll([
|
||||
id,
|
||||
points,
|
||||
width,
|
||||
visible,
|
||||
geodesic,
|
||||
alpha,
|
||||
dashLineType,
|
||||
capType,
|
||||
joinType,
|
||||
color
|
||||
]);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user