'Error: The non-abstract class 'InternalSelectableMathState'
I just updated flutter version from 2.5.3 to 2.8. I have the following error that i dont know how resolve it. There is no error on any plugin installed, It seems that the error comes from the inner classes themselves and I don't know in which part of my application the error is throwed:
../../AppData/Local/Pub/Cache/hosted/pub.dartlang.org/flutter_math_fork-0.3.3+1/lib/src/widgets/selectable.dart:407:7: Error: The non-abstract class 'InternalSelectableMathState' is missing implementations for these members:
- TextSelectionDelegate.copySelection
- TextSelectionDelegate.cutSelection
- TextSelectionDelegate.pasteText
- TextSelectionDelegate.selectAll
Try to either
- provide an implementation,
- inherit an implementation from a superclass or mixin,
- mark the class as abstract, or
- provide a 'noSuchMethod' implementation.
class InternalSelectableMathState extends State<InternalSelectableMath>
^^^^^^^^^^^^^^^^^^^^^^^^^^^
/C:/desarrollo/flutter/packages/flutter/lib/src/services/text_input.dart:985:8: Context: 'TextSelectionDelegate.copySelection' is defined here.
void copySelection(SelectionChangedCause cause);
^^^^^^^^^^^^^
/C:/desarrollo/flutter/packages/flutter/lib/src/services/text_input.dart:965:8: Context: 'TextSelectionDelegate.cutSelection' is defined here.
void cutSelection(SelectionChangedCause cause);
^^^^^^^^^^^^
/C:/desarrollo/flutter/packages/flutter/lib/src/services/text_input.dart:973:16: Context: 'TextSelectionDelegate.pasteText' is defined here.
Future<void> pasteText(SelectionChangedCause cause);
^^^^^^^^^
/C:/desarrollo/flutter/packages/flutter/lib/src/services/text_input.dart:979:8: Context: 'TextSelectionDelegate.selectAll' is defined here.
void selectAll(SelectionChangedCause cause);
^^^^^^^^^
FAILURE: Build failed with an exception.
* Where:
Script 'C:\desarrollo\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1070
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\desarrollo\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 8m 5s
Exception: Gradle task assembleDebug failed with exit code 1
I dont have declared flutter_math_fork
on my pubspec.
My flutter doctor output:
Doctor summary (to see all details, run flutter doctor -v): [√] Flutter (Channel stable, 2.8.0, on Microsoft Windows [Versión 10.0.19041.1348], locale es-ES) [√] Android toolchain - develop for Android devices (Android SDK version 31.0.0) [√] Chrome - develop for the web [√] Android Studio (version 2020.3) [√] VS Code (version 1.62.3) [√] Connected device (3 available) • No issues found!
I have tried: flutter clean, flutter upgrade and invalidate cache / restart.
Any suggestion is appreciated.
Solution 1:[1]
I have solved it by forcing update flutter_math_fork
adding to pubspec:
flutter_math_fork: ^0.5.0
I dont know why flutter install flutter_math_fork-0.3.3+1
when i upgrade to 2.8 stable version.
Solution 2:[2]
I have solved this with
flutter pub upgrade --major-versions
Solution 3:[3]
First Try to update your flutter_math_fork
to 0.6.0 but in my case
I got the same error after updating the flutter version to 2.8.1 and I can't update flutter_math_fork
to latest version because I was using Provider version 5.0.0
and flutter_math_form
require provider version 6.0.0+
. So until upgrading other libraries you can modified /lib/src/widgets/selectable.dart
this file. add this line.
@override
dynamic noSuchMethod(Invocation invocation) {
// We override noSuchMethod since we do not have concrete implementations
// for all methods of the selection manager mixins.
throw NoSuchMethodError.withInvocation(this, invocation);
}
}
remove this method
@override
void bringIntoView(TextPosition position) {}
@override
void userUpdateTextEditingValue(
TextEditingValue value, SelectionChangedCause cause) {}
}
Or just copy paste this
Solution 4:[4]
Add to your pubspec.yaml. It's worked for me.
dependency_overrides:
flutter_math_fork: ^0.5.0
provider: ^6.0.2
Solution 5:[5]
I got this error when building only with codemagic, but not on my local M1 mac.
One of my dependencies (flag) had a conflict with flutter_math_fork: ^0.5.0.
I was able to get it work with flutter_math_fork: ^0.4.2+2. Codemagic build succeeded.
Solution 6:[6]
I faced the same error, i add following codes to pubscpec.yaml, it's working now. If it doesn't work you can follow the above methods
dependency_overrides:
provider: 6.0.0
Solution 7:[7]
In my case:
Step 1: Update the dependencies in pubspec.yaml with the following:
- provider: ^6.0.0
- flutter_svg: ^0.23.0+1
- flutter_math_fork: ^0.5.0
Step 2: Run flutter pub get
Step 3: Run: flutter run
Good luck!
Solution 8:[8]
The way to resolve problems like this which occur after updating to a new Flutter version are to find out where the problem actually lies. The answer will vary depending on what dependencies you have in your pubspec.yaml
, so many of the answers here may not work for you.
The problem is that packages that you add to your pubspec.yaml
also have their own list of packages that they depend on, and those packages may also have a list of packages that they depend on, and so on. These are called transient dependencies. The result is that your app relies on a whole bunch of packages in a big dependency "tree". When you update the version of Flutter that you use for your app, ALL of these dependencies must support the new version. This is why you can randomly get problems like these popping up when upgrading, often for packages that you had no idea were part of your app! (like flutter_math_fork
).
The first thing to do is print your dependency tree. From the command line / terminal, in your app's root directory, run:
flutter pub deps
This will print the dependency tree. Search it, looking for flutter_math_fork
. If the tree is big, you might want to save it to a file which is easier to search, for example:
flutter pub deps > deps.txt
In my case, I found it here:
-- flutter_html 2.1.5
| |-- chewie 1.2.2
| | |-- cupertino_icons 1.0.3
| | |-- flutter...
| | |-- provider 5.0.0
| | | |-- collection...
| | | |-- flutter...
| | | '-- nested 1.0.0
| | | '-- flutter...
| | |-- video_player...
| | '-- wakelock...
...
| |-- flutter_math_fork 0.3.3+1 <-----------
| | |-- collection...
| | |-- flutter...
| | |-- flutter_svg...
| | |-- meta...
| | |-- provider...
| | '-- tuple...
This told me that the package flutter_html
, which I have in my pubspec.yaml, was the one which has a transient dependency on the offending flutter_math_fork, whose version (0.3.3+1) was too old to support newer versions of Flutter.
So, the solution was to update my version of flutter_html
. For you, it may be a different package, or multiple packages. Whichever package it is, go to it's Change Log page on pub.dev and look at the change notes for later versions - hopefully you will see something like "updated dependencies" for one of the newer versions.
In my case, I was using flutter_html version 2.1.5. Going to the change log for flutter_html, there is a note under version 2.2.0:
Bumped minimum flutter_math_fork version for Flutter 2.5 compatibility
Fantastic! So I updated my version of flutter_html to 2.2.0, ran flutter pub get
and viola - the problem is resolved.
If you don't see any later versions in the Change Log which update the dependencies, try using the latest version. If this doesn't fix the problem, you need to report this problem with the package authors. Until they fix it, you either have to revert back to the earlier versions of Flutter, or remove the package from your app.
Of course, you could also just use flutter pub upgrade
to update ALL your packages at the same time, but if your project is big, make sure to allocate at least the entire day to possibly fixing breaking changes, dependency problems and bugs.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Maikzen |
Solution 2 | Mustafa Ali Dikçinar |
Solution 3 | Shailandra Rajput |
Solution 4 | Dansp |
Solution 5 | E G |
Solution 6 | Yasin Ege |
Solution 7 | Hai Dinh |
Solution 8 |