The argument type 'PointerEvent' can't be assigned to the parameter type 'PointerDownEvent'

5,820

Solution 1

There was an API change in version 2.5 of flutter and several packages must update accordingly. Your logs show that the exact package which contains the error is photo_view.

Luckily enough the package has just been updated to fix this, so just update its version in your pubspec.yaml:

photo_view: ^0.12.0

UPDATE

If you don't have the package directly in your pubspec

You have two options

1 It's probably a transient dependency, you can run flutter pub deps to list the installed packages and its dependencies and try to update the one that uses photo_view (if it does have an update)

2 Add a dependency override to your pubspec.yaml, this will effectively override the version of the package being used

dependency_overrides:
  photo_view: ^0.12.0

Add this just before your dev_dependencies

Solution 2

from your debug code ('../plugins/flutter/packages/flutter/lib/src/gestures/events.dart'). you open the file or click if there are link clickable

Search for this:

void addAllowedPointer(PointerEvent event) {

and replace with this:

void addAllowedPointer(PointerDownEvent event) {

Here is the reference link

https://flutter.dev/docs/release/breaking-changes/gesture-recognizer-add-allowed-pointer

Solution 3

This problem arises due to the GestureRecognizer Cleanup - Here is the documentation if you are intrested in the migration code

But in case you just want to build your flutter app without any migrations following are couple of solutions to that problem

  1. You can update photo_view dependency in your pubspec.yaml file to
    photo_view :^0.12.0
  2. If you do not want to update your dependency due to any reason you can opt for this temporary fix . In the pubspec.yaml file add the following custom photo_view with better gesture recognition in dependency_overrides.

dependency_overrides:

   photo_view:
     git: git://github.com/robertodoering/photo_view.git
Share:
5,820
jeffmayn
Author by

jeffmayn

Computer Scientist

Updated on January 01, 2023

Comments

  • jeffmayn
    jeffmayn over 1 year

    Recently I've updated to flutter 2.5 and the newest androids studio, and tried to compile my flutter project to android device. Android studio throws me the error below. If I write flutter run in a terminal there is no problem compiling to android device.

    Guess this must be related to android studio. I tried downgrade to an earlier android studio version, but the problem persists.

    I'm not sure what plugin this is, it doesn't seem like any I use in my project.

    Edit: If I downgrade flutter from 2.5 to 2.0 my project compiles again. So the problem is within flutter 2.5

    Launching lib/main.dart on Android SDK built for x86 in debug mode...
    Running Gradle task 'assembleDebug'...
    ../plugins/flutter/.pub-cache/hosted/pub.dartlang.org/photo_view-0.11.1/lib/src/core/photo_view_gesture_detector.dart:106:29: Error: The argument type 'PointerEvent' can't be assigned to the parameter type 'PointerDownEvent'.
     - 'PointerEvent' is from 'package:flutter/src/gestures/events.dart' ('../plugins/flutter/packages/flutter/lib/src/gestures/events.dart').
     - 'PointerDownEvent' is from 'package:flutter/src/gestures/events.dart' ('../plugins/flutter/packages/flutter/lib/src/gestures/events.dart').
        super.addAllowedPointer(event);
    
  • jeffmayn
    jeffmayn over 2 years
    I don't have photo_view in my pubspec.yaml
  • Mithson
    Mithson over 2 years
    I am facing the same problem but mine is with html_editor_enhanced which includes this flutter_colorpicker as dependency what should I do then
  • croxx5f
    croxx5f over 2 years
    @AbhishekVishwakarma, the same dependency_overrides: flutter_colorpicker: ^versionWhichUsesNewAPI. You could try the latest one in pub.dev or check its changelog
  • Mithson
    Mithson over 2 years
    @croxx5f My pubspec is all up-to-date so how can I check its changelog and fix
  • croxx5f
    croxx5f over 2 years
    @AbhishekVishwakarma in the package page in pub.dev. If you dont find info there then in Github. If after that you dont seem to fix your issue I would encourage you to make a new question
  • Admin
    Admin over 2 years
    As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
  • Admin
    Admin over 2 years
    As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
  • Shemang David
    Shemang David over 2 years
    This solution worked for me.