Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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);
like image 719
jeffmayn Avatar asked Sep 10 '21 19:09

jeffmayn


3 Answers

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

like image 158
croxx5f Avatar answered Oct 22 '22 21:10

croxx5f


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

like image 37
Charles Lim Avatar answered Oct 22 '22 21:10

Charles Lim


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
like image 36
Roopak Avatar answered Oct 22 '22 19:10

Roopak