Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 646
Maikzen Avatar asked Dec 13 '21 12:12

Maikzen


7 Answers

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.

like image 129
Maikzen Avatar answered Oct 24 '22 07:10

Maikzen


I have solved this with

flutter pub upgrade --major-versions
like image 5
Mustafa Ali Dikçinar Avatar answered Oct 24 '22 06:10

Mustafa Ali Dikçinar


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

like image 5
Shailandra Rajput Avatar answered Oct 24 '22 08:10

Shailandra Rajput


Add to your pubspec.yaml. It's worked for me.

dependency_overrides:
   flutter_math_fork: ^0.5.0
   provider: ^6.0.2
like image 6
Dansp Avatar answered Oct 24 '22 08:10

Dansp


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.

like image 2
E G Avatar answered Oct 24 '22 08:10

E G


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
like image 1
Yasin Ege Avatar answered Oct 24 '22 08:10

Yasin Ege


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!

enter image description here

like image 1
Hai Dinh Avatar answered Oct 24 '22 06:10

Hai Dinh