错误:在我的项目中导入颜色选择器包时,方法“AlwaysWinPanGestureRecognizer...”的参数“事件”
Posted
技术标签:
【中文标题】错误:在我的项目中导入颜色选择器包时,方法“AlwaysWinPanGestureRecognizer...”的参数“事件”【英文标题】:Error: The parameter 'event' of the method 'AlwaysWinPanGestureRecognizer... when importing color picker package in my project 【发布时间】:2021-09-02 09:57:44 【问题描述】:欢迎
我在导入 flutter_colorpicker package 时遇到问题
当我将它导入我的项目时:
import 'package:flutter_colorpicker/flutter_colorpicker.dart';
我收到此错误:
/C:/src/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_colorpicker-0.5.0/lib/src/hsv_picker.dart:730:43: Error: The parameter 'event' of the method 'AlwaysWinPanGestureRecognizer.addAllowedPointer' has type 'PointerDownEvent', which does not match the corresponding type, 'PointerEvent', in the overridden method, 'DragGestureRecognizer.addAllowedPointer'.
- 'PointerDownEvent' is from 'package:flutter/src/gestures/events.dart' ('/C:/src/flutter/packages/flutter/lib/src/gestures/events.dart').
- 'PointerEvent' is from 'package:flutter/src/gestures/events.dart' ('/C:/src/flutter/packages/flutter/lib/src/gestures/events.dart').
Change to a supertype of 'PointerEvent', or, for a covariant parameter, a subtype.
void addAllowedPointer(PointerDownEvent event)
^
/C:/src/flutter/packages/flutter/lib/src/gestures/monodrag.dart:256:8: Context: This is the overridden method ('addAllowedPointer').
void addAllowedPointer(PointerEvent event)
^
这是颤振医生的结果:
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel stable, 2.2.1, on Microsoft Windows [Version 10.0.17763.1577], locale en-US)
[√] android toolchain - develop for Android devices (Android SDK version 30.0.3)
[√] Chrome - develop for the web
[√] Android Studio (version 3.6)
[√] IntelliJ IDEA Community Edition (version 2021.1)
[√] VS Code (version 1.56.2)
[√] Connected device (3 available)
• No issues found!
这是项目的依赖:
dependencies:
flutter:
sdk: flutter
shared_preferences: ^2.0.6
flutter_colorpicker: ^0.5.0
有人有解决办法吗? 感谢每一个人
【问题讨论】:
github.com/mchome/flutter_colorpicker/issues/… 【参考方案1】:只需将 flutter_colorpicker 版本更改为 0.4.0
【讨论】:
更新flutter_colorpicker版本到^0.6.1【参考方案2】:一种选择是将协变关键字添加到方法中 addAllowedPointer(协变 PointerEvent 事件)
出现错误,但此选项只能解决您计算机上的问题
【讨论】:
【参考方案3】:这些可能会有所帮助: 将 pubspec.yaml 中的依赖项更改为:
dependencies:
flutter:
sdk: flutter
flutter_colorpicker: ^0.6.0
运行flutter clean,然后再次添加对我有用的依赖项:)
【讨论】:
以上是关于错误:在我的项目中导入颜色选择器包时,方法“AlwaysWinPanGestureRecognizer...”的参数“事件”的主要内容,如果未能解决你的问题,请参考以下文章
TypeScript 导入 vue 包时出错(vue-cli3 proj)
Flask开发 导入flask_uploads包时提示“IMPORTERROR: CANNOT IMPORT NAME ‘SECURE_FILENAME‘ FROM ‘WERKZEUG‘“
Flask开发 导入flask_uploads包时提示“IMPORTERROR: CANNOT IMPORT NAME ‘SECURE_FILENAME‘ FROM ‘WERKZEUG‘“