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);
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
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
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
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
photo_view
dependency in your pubspec.yaml
file tophoto_view :^0.12.0
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With