How can I resolve the argument type error in gesture_detector_builder.dart related to TapDownDetails and TapDragDownDetails in Flutter?

huangapple go评论67阅读模式
英文:

How can I resolve the argument type error in gesture_detector_builder.dart related to TapDownDetails and TapDragDownDetails in Flutter?

问题

Error: 参数类型 'void Function(TapDownDetails)' 不能赋值给参数类型 'void Function(TapDragDownDetails)?'。

  • 'TapDownDetails' 来自 'package:flutter/src/gestures/tap.dart' ('/C:/Flutter/flutter/packages/flutter/lib/src/gestures/tap.dart')。
  • 'TapDragDownDetails' 来自 'package:flutter/src/widgets/tap_and_drag_gestures.dart' ('/C:/Flutter/flutter/packages/flutter/lib/src/widgets/tap_and_drag_gestures.dart')。
    onTapDown: onTapDown,
    ^

Error: 参数类型 'void Function(TapUpDetails)' 不能赋值给参数类型 'void Function(TapDragUpDetails)?'。

  • 'TapUpDetails' 来自 'package:flutter/src/gestures/tap.dart' ('/C:/Flutter/flutter/packages/flutter/lib/src/gestures/tap.dart')。
  • 'TapDragUpDetails' 来自 'package:flutter/src/widgets/tap_and_drag_gestures.dart' ('/C:/Flutter/flutter/packages/flutter/lib/src/widgets/tap_and_drag_gestures.dart')。
    onSingleTapUp: onSingleTapUp,
    ^

Error: 参数类型 'void Function(TapDownDetails)' 不能赋值给参数类型 'void Function(TapDragDownDetails)?'。

  • 'TapDownDetails' 来自 'package:flutter/src/gestures/tap.dart' ('/C:/Flutter/flutter/packages/flutter/lib/src/gestures/tap.dart')。
  • 'TapDragDownDetails' 来自 'package:flutter/src/widgets/tap_and_drag_gestures.dart' ('/C:/Flutter/flutter/packages/flutter/lib/src/widgets/tap_and_drag_gestures.dart')。
    onDoubleTapDown: onDoubleTapDown,
    ^

Error: 参数类型 'void Function(DragStartDetails)' 不能赋值给参数类型 'void Function(TapDragStartDetails)?'。

  • 'DragStartDetails' 来自 'package:flutter/src/gestures/drag_details.dart' ('/C:/Flutter/flutter/packages/flutter/lib/src/gestures/drag_details.dart')。
  • 'TapDragStartDetails' 来自 'package:flutter/src/widgets/tap_and_drag_gestures.dart' ('/C:/Flutter/flutter/packages/flutter/lib/src/widgets/tap_and_drag_gestures.dart')。
    onDragSelectionStart: onDragSelectionStart,
    ^

Error: 参数类型 'void Function(DragStartDetails, DragUpdateDetails)' 不能赋值给参数类型 'void Function(TapDragUpdateDetails)?'。

  • 'DragStartDetails' 来自 'package:flutter/src/gestures/drag_details.dart' ('/C:/Flutter/flutter/packages/flutter/lib/src/gestures/drag_details.dart')。
  • 'DragUpdateDetails' 来自 'package:flutter/src/gestures/drag_details.dart' ('/C:/Flutter/flutter/packages/flutter/lib/src/gestures/drag_details.dart')。
  • 'TapDragUpdateDetails' 来自 'package:flutter/src/widgets/tap_and_drag_gestures.dart' ('/C:/Flutter/flutter/packages/flutter/lib/src/widgets/tap_and_drag_gestures.dart')。
    onDragSelectionUpdate: onDragSelectionUpdate,
    ^

Error: 参数类型 'void Function(DragEndDetails)' 不能赋值给参数类型 'void Function(TapDragEndDetails)?'。

  • 'DragEndDetails' 来自 'package:flutter/src/gestures/drag_details.dart' ('/C:/Flutter/flutter/packages/flutter/lib/src/gestures/drag_details.dart')。
  • 'TapDragEndDetails' 来自 'package:flutter/src/widgets/tap_and_drag_gestures.dart' ('/C:/Flutter/flutter/packages/flutter/lib/src/widgets/tap_and_drag_gestures.dart')。
    onDragSelectionEnd: onDragSelectionEnd,
    ^

构建失败:Gradle 任务 assembleDebug 失败,退出代码为 1

  • 位置:
    脚本 'C:\Flutter\flutter\packages\flutter_tools\gradle\flutter.gradle' 第 1201 行

  • 出错原因:
    任务 ':app:compileFlutterBuildDebug' 执行失败。

  • 尝试:
    运行时使用 --stacktrace 选项获取堆栈跟踪。
    运行时使用 --info 或 --debug 选项获取更多日志输出。
    运行时使用 --scan 获取完整的洞察信息。

  • https://help.gradle.org 获取更多帮助。

构建在 1 分 50 秒内失败
E/AndroidRuntime(29997): 致命异常:ScreenDecorations
E/AndroidRuntime(29997): 进程:com.android.systemui,PID:29997
E/AndroidRuntime(29997): java.lang.NullPointerException:指定为非 null 的参数为 null:方法 kotlin.jvm.internal.Intrinsics.checkNotNullParameter,参数 bottomLeft
E/AndroidRuntime(29997): at com.android.systemui.statusbar.events.PrivacyDotViewController.initialize(Unknown Source:22)
E/AndroidRuntime(29997): at com.android.systemui.ScreenDecorations.setupDecorations(ScreenDecorations.java:315)
E/AndroidRuntime(29997): at com.android.systemui.ScreenDecorations.startOnScreenDecorationsThread(ScreenDecorations.java:252)
E/AndroidRuntime(29997): at com.android.systemui.ScreenDecorations.$r8$lambda$bRx4s-frKyGv-SmpobluoualBbQ(Unknown Source:0)
E/AndroidRuntime(29997): at com.android.systemui.ScreenDecorations$$ExternalSyntheticLambda2.run(Unknown Source:2)
E/AndroidRuntime(29997): at android.os.Handler.handleCallback(Handler.java:938)
E/AndroidRuntime(29997): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(29997): at android.os.Looper.loopOnce(Looper.java:201)
E/AndroidRuntime(29997): at android.os.Looper.loop(Looper.java:288)
E/AndroidRuntime(29997): at android.os.HandlerThread.run(HandlerThread.java:67)
异常:Gradle 任务 assembleDebug 失败,退出码为 1
已退出(SIGTERM)

我想要更新我的应用程序,所以我只需更新了包以及 Flutter。然后当我运行它时,抛出上述错误。
这是我的 pubspec.yaml packages:
http: ^1.0.0
webfeed: 0.7.0
xml: ^5.4.1
cupertino_icons: 1.0.5
flutter_launcher_icons: ^0.11.0
shared_preferences: ^2.1.1
share: 2.0.4
launch_review: 3.0.1
url_launcher: ^6.1.11
fluttertoast: ^8.2.2
font_awesome_flutter: 10.4.0
webview_flutter: ^2.3.4
flutter_html: 2.2.1
percent

英文:

: Error: The argument type 'void Function(TapDownDetails)' can't be assigned to the parameter type 'void Function(TapDragDownDetails)?'.

  • 'TapDownDetails' is from 'package:flutter/src/gestures/tap.dart' ('/C:/Flutter/flutter/packages/flutter/lib/src/gestures/tap.dart').
  • 'TapDragDownDetails' is from 'package:flutter/src/widgets/tap_and_drag_gestures.dart' ('/C:/Flutter/flutter/packages/flutter/lib/src/widgets/tap_and_drag_gestures.dart').
    onTapDown: onTapDown,
    ^
    : Error: The argument type 'void Function(TapUpDetails)' can't be assigned to the parameter type 'void Function(TapDragUpDetails)?'.
  • 'TapUpDetails' is from 'package:flutter/src/gestures/tap.dart' ('/C:/Flutter/flutter/packages/flutter/lib/src/gestures/tap.dart').
  • 'TapDragUpDetails' is from 'package:flutter/src/widgets/tap_and_drag_gestures.dart' ('/C:/Flutter/flutter/packages/flutter/lib/src/widgets/tap_and_drag_gestures.dart').
    onSingleTapUp: onSingleTapUp,
    ^
    : Error: The argument type 'void Function(TapDownDetails)' can't be assigned to the parameter type 'void Function(TapDragDownDetails)?'.
  • 'TapDownDetails' is from 'package:flutter/src/gestures/tap.dart' ('/C:/Flutter/flutter/packages/flutter/lib/src/gestures/tap.dart').
  • 'TapDragDownDetails' is from 'package:flutter/src/widgets/tap_and_drag_gestures.dart' ('/C:/Flutter/flutter/packages/flutter/lib/src/widgets/tap_and_drag_gestures.dart').
    onDoubleTapDown: onDoubleTapDown,
    ^
    : Error: The argument type 'void Function(DragStartDetails)' can't be assigned to the parameter type 'void Function(TapDragStartDetails)?'.
  • 'DragStartDetails' is from 'package:flutter/src/gestures/drag_details.dart' ('/C:/Flutter/flutter/packages/flutter/lib/src/gestures/drag_details.dart').
  • 'TapDragStartDetails' is from 'package:flutter/src/widgets/tap_and_drag_gestures.dart' ('/C:/Flutter/flutter/packages/flutter/lib/src/widgets/tap_and_drag_gestures.dart').
    onDragSelectionStart: onDragSelectionStart,
    ^
    : Error: The argument type 'void Function(DragStartDetails, DragUpdateDetails)' can't be assigned to the parameter type 'void Function(TapDragUpdateDetails)?'.
  • 'DragStartDetails' is from 'package:flutter/src/gestures/drag_details.dart' ('/C:/Flutter/flutter/packages/flutter/lib/src/gestures/drag_details.dart').
  • 'DragUpdateDetails' is from 'package:flutter/src/gestures/drag_details.dart' ('/C:/Flutter/flutter/packages/flutter/lib/src/gestures/drag_details.dart').
  • 'TapDragUpdateDetails' is from 'package:flutter/src/widgets/tap_and_drag_gestures.dart' ('/C:/Flutter/flutter/packages/flutter/lib/src/widgets/tap_and_drag_gestures.dart').
    onDragSelectionUpdate: onDragSelectionUpdate,
    ^
    : Error: The argument type 'void Function(DragEndDetails)' can't be assigned to the parameter type 'void Function(TapDragEndDetails)?'.
  • 'DragEndDetails' is from 'package:flutter/src/gestures/drag_details.dart' ('/C:/Flutter/flutter/packages/flutter/lib/src/gestures/drag_details.dart').
  • 'TapDragEndDetails' is from 'package:flutter/src/widgets/tap_and_drag_gestures.dart' ('/C:/Flutter/flutter/packages/flutter/lib/src/widgets/tap_and_drag_gestures.dart').
    onDragSelectionEnd: onDragSelectionEnd,
    ^

FAILURE: Build failed with an exception.

  • Where:
    Script 'C:\Flutter\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1201

  • What went wrong:
    Execution failed for task ':app:compileFlutterBuildDebug'.
    > Process 'command 'C:\Flutter\flutter\bin\flutter.bat'' finished with non-zero exit value 1

  • Try:
    > Run with --stacktrace option to get the stack trace.
    > Run with --info or --debug option to get more log output.
    > Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 1m 50s
E/AndroidRuntime(29997): FATAL EXCEPTION: ScreenDecorations
E/AndroidRuntime(29997): Process: com.android.systemui, PID: 29997
E/AndroidRuntime(29997): java.lang.NullPointerException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkNotNullParameter, parameter bottomLeft
E/AndroidRuntime(29997): at com.android.systemui.statusbar.events.PrivacyDotViewController.initialize(Unknown Source:22)
E/AndroidRuntime(29997): at com.android.systemui.ScreenDecorations.setupDecorations(ScreenDecorations.java:315)
E/AndroidRuntime(29997): at com.android.systemui.ScreenDecorations.startOnScreenDecorationsThread(ScreenDecorations.java:252)
E/AndroidRuntime(29997): at com.android.systemui.ScreenDecorations.$r8$lambda$bRx4s-frKyGv-SmpobluoualBbQ(Unknown Source:0)
E/AndroidRuntime(29997): at com.android.systemui.ScreenDecorations$$ExternalSyntheticLambda2.run(Unknown Source:2)
E/AndroidRuntime(29997): at android.os.Handler.handleCallback(Handler.java:938)
E/AndroidRuntime(29997): at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(29997): at android.os.Looper.loopOnce(Looper.java:201)
E/AndroidRuntime(29997): at android.os.Looper.loop(Looper.java:288)
E/AndroidRuntime(29997): at android.os.HandlerThread.run(HandlerThread.java:67)
Exception: Gradle task assembleDebug failed with exit code 1
Exited (sigterm)

I wanted to update my application so I just updated the packages along with flutter.After which when I run it, throws the above errors.
Here's my pubspec.yaml packages:
http: ^1.0.0
webfeed: 0.7.0
xml: ^5.4.1
cupertino_icons: 1.0.5
flutter_launcher_icons: ^0.11.0
shared_preferences: ^2.1.1
share: 2.0.4
launch_review: 3.0.1
url_launcher: ^6.1.11
fluttertoast: ^8.2.2
font_awesome_flutter: 10.4.0
webview_flutter: ^2.3.4
flutter_html: 2.2.1
percent_indicator: 4.2.3
page_indicator: ^0.4.1
admob_flutter: ^3.0.0
flutter_local_notifications: ^12.0.4

答案1

得分: 3

我在将Flutter升级到版本3.10.4后遇到了这个错误。
问题出在flutter_html包上。它依赖于flutter_math_fork 0.5.0,这个版本会引发Gesture_detector错误。一旦我用另一个HTML渲染包替换了flutter_html,错误就解决了。

英文:

I faced this error after upgrading Flutter to version 3.10.4.
The issue lies with the flutter_html package. It depends on the flutter_math_fork 0.5.0 which throws the Gesture_detector error. Once I replaced the flutter_html with a different HTML rendering package the error was resolved

答案2

得分: 1

  • flutter clean
  • flutter pub upgrade
  • flutter pub outdated
  • flutter pub upgrade --major-versions
  • flutter pub get

then run it

英文:

Try these commands on your terminal :

  • flutter clean
  • fluter pub upgrade
  • flutter pub outdated
  • flutter pub upgrade --major-versions
  • flutter pub get

then run it

答案3

得分: 0

我不知道为什么,在2/3次的“clean”和“get”之后,问题就解决了。

英文:

I don't know why, after 2/3 times of clean and get, it was solved for me

答案4

得分: 0

dependencies:
flutter_html: ^3.0.0-beta.2

英文:

I was facing the same issue updating flutter version. Flutter html package has now new version just add will solve the issue !

dependencies:
  flutter_html: ^3.0.0-beta.2

huangapple
  • 本文由 发表于 2023年6月5日 15:25:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/76404279.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定