release: 1.0.12

This commit is contained in:
Kuloud
2024-08-26 09:55:49 +08:00
parent 43ecfb8ca1
commit 0a6e9c7119
36 changed files with 172 additions and 172 deletions

View File

@ -223,7 +223,7 @@ class _MapState extends State<AMapWidget> {
@override
void deactivate() async {
super.deactivate();
print('deactivate AMapWidget}');
print('deactivate AMapWidget');
}
@override

View File

@ -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())

View File

@ -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
]);
}

View File

@ -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>[];

View File

@ -188,6 +188,15 @@ class Polyline extends BaseOverlay {
@override
int get hashCode => Object.hashAll([
id,
points,
width,
visible,
geodesic,
alpha,
dashLineType,
capType,
joinType,
color
]);
}