class 'TapListener' 是抽象的,不能实例化
The class 'TapListener' is abstract and can't be instantiated
我正在使用 HERE Maps SDK for Flutter,版本 4.6.4 探索版。
我的问题
我正在尝试向地图添加点击侦听器。我在关注官方documentation
void _setTapGestureHandler() {
_hereMapController.gestures.tapListener = TapListener((Point2D touchPoint) {
var geoCoordinates = _toString(_hereMapController.viewToGeoCoordinates(touchPoint));
print('Tap at: $geoCoordinates');
});
}
这就是我得到的
Error: The class 'TapListener' is abstract and can't be instantiated.
_hereMapController.gestures.tapListener = TapListener((Point2D touchPoint) {
^^^^^^^^^^^
可能下个版本会有修复,但是我需要这个版本SDK的解决方案。
对于遇到相同问题的人,找到了解决方案。看起来这里从文档或 smth 中删除了它。
这是方法。
_hereMapController.gestures.tapListener = TapListener.fromLambdas(
lambda_onTap: (Point2D touchPoint) => _yourFunction(touchPoint));
您问题中显示的代码对于 HERE SDK 版本大于或等于 4.7.7.0 是正确的。在 release notes 中宣布删除 Lambda 符号。
“fromLambda”构造函数已从所有使用它的 Dart 类 中删除,例如 Gestures
、MapDownloader
、SearchEngine
等。现在可以将代码简化为:tapListener = TapListener((Point2D p) { ... });
.
,而不是像这样创建手势侦听器:tapListener = TapListener.fromLambdas(lambda_onTap: (Point2D p) { ... });
浏览HERE SDK文档时,请查看版本下拉列表:
您的 post 中的 link 转到更新版本。
其次,在查找示例应用程序时,选择为所需版本制作的应用程序,转到 GitHub 和 select 标签:
我正在使用 HERE Maps SDK for Flutter,版本 4.6.4 探索版。
我的问题
我正在尝试向地图添加点击侦听器。我在关注官方documentation
void _setTapGestureHandler() {
_hereMapController.gestures.tapListener = TapListener((Point2D touchPoint) {
var geoCoordinates = _toString(_hereMapController.viewToGeoCoordinates(touchPoint));
print('Tap at: $geoCoordinates');
});
}
这就是我得到的
Error: The class 'TapListener' is abstract and can't be instantiated. _hereMapController.gestures.tapListener = TapListener((Point2D touchPoint) { ^^^^^^^^^^^
可能下个版本会有修复,但是我需要这个版本SDK的解决方案。
对于遇到相同问题的人,找到了解决方案。看起来这里从文档或 smth 中删除了它。
这是方法。
_hereMapController.gestures.tapListener = TapListener.fromLambdas(
lambda_onTap: (Point2D touchPoint) => _yourFunction(touchPoint));
您问题中显示的代码对于 HERE SDK 版本大于或等于 4.7.7.0 是正确的。在 release notes 中宣布删除 Lambda 符号。
“fromLambda”构造函数已从所有使用它的 Dart 类 中删除,例如 Gestures
、MapDownloader
、SearchEngine
等。现在可以将代码简化为:tapListener = TapListener((Point2D p) { ... });
.
tapListener = TapListener.fromLambdas(lambda_onTap: (Point2D p) { ... });
浏览HERE SDK文档时,请查看版本下拉列表:
您的 post 中的 link 转到更新版本。
其次,在查找示例应用程序时,选择为所需版本制作的应用程序,转到 GitHub 和 select 标签: