错误:非抽象类“InternalSelectableMathState”

Mai*_*zen 15 dart flutter flutter-dependencies

我刚刚将 flutter 版本从 2.5.3 更新到 2.8。我有以下错误,我不知道如何解决它。安装的任何插件都没有错误,似乎错误来自内部类本身,我不知道在我的应用程序的哪个部分抛出错误:

\n
../../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:\n - TextSelectionDelegate.copySelection\n - TextSelectionDelegate.cutSelection\n - TextSelectionDelegate.pasteText\n - TextSelectionDelegate.selectAll\nTry to either\n - provide an implementation,\n - inherit an implementation from a superclass or mixin,\n - mark the class as abstract, or\n - provide a 'noSuchMethod' implementation.\n\nclass InternalSelectableMathState extends State<InternalSelectableMath>\n      ^^^^^^^^^^^^^^^^^^^^^^^^^^^\n/C:/desarrollo/flutter/packages/flutter/lib/src/services/text_input.dart:985:8: Context: 'TextSelectionDelegate.copySelection' is defined here.\n  void copySelection(SelectionChangedCause cause);\n       ^^^^^^^^^^^^^\n/C:/desarrollo/flutter/packages/flutter/lib/src/services/text_input.dart:965:8: Context: 'TextSelectionDelegate.cutSelection' is defined here.\n  void cutSelection(SelectionChangedCause cause);\n       ^^^^^^^^^^^^\n/C:/desarrollo/flutter/packages/flutter/lib/src/services/text_input.dart:973:16: Context: 'TextSelectionDelegate.pasteText' is defined here.\n  Future<void> pasteText(SelectionChangedCause cause);\n               ^^^^^^^^^\n/C:/desarrollo/flutter/packages/flutter/lib/src/services/text_input.dart:979:8: Context: 'TextSelectionDelegate.selectAll' is defined here.\n  void selectAll(SelectionChangedCause cause);\n       ^^^^^^^^^\n\n\nFAILURE: Build failed with an exception.\n\n* Where:\nScript 'C:\\desarrollo\\flutter\\packages\\flutter_tools\\gradle\\flutter.gradle' line: 1070\n\n* What went wrong:\nExecution failed for task ':app:compileFlutterBuildDebug'.\n> Process 'command 'C:\\desarrollo\\flutter\\bin\\flutter.bat'' finished with non-zero exit value 1\n\n* Try:\nRun 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.\n\n* Get more help at https://help.gradle.org\n\nBUILD FAILED in 8m 5s\nException: Gradle task assembleDebug failed with exit code 1\n
Run Code Online (Sandbox Code Playgroud)\n

我没有flutter_math_fork在我的 pubspec 上声明。

\n

我的颤振医生输出:

\n
\n
Doctor summary (to see all details, run flutter doctor -v):\n[\xe2\x88\x9a] Flutter (Channel stable, 2.8.0, on Microsoft Windows [Versi\xc3\x83\xc2\xb3n 10.0.19041.1348], locale es-ES)\n[\xe2\x88\x9a] Android toolchain - develop for Android devices (Android SDK version 31.0.0)\n[\xe2\x88\x9a] Chrome - develop for the web\n[\xe2\x88\x9a] Android Studio (version 2020.3)\n[\xe2\x88\x9a] VS Code (version 1.62.3)\n[\xe2\x88\x9a] Connected device (3 available)\n\n\xe2\x80\xa2 No issues found!\n
Run Code Online (Sandbox Code Playgroud)\n
\n

我尝试过:flutter clean、flutter Upgrade 和使缓存无效/重新启动。

\n

任何建议表示赞赏。

\n

Mai*_*zen 17

flutter_math_fork我通过强制更新添加到 pubspec解决了这个问题:

flutter_math_fork: ^0.5.0
Run Code Online (Sandbox Code Playgroud)

flutter_math_fork-0.3.3+1我不知道为什么升级到 2.8 稳定版本后会安装 flutter 。


Mus*_*nar 7

我已经解决了这个问题

flutter pub upgrade --major-versions
Run Code Online (Sandbox Code Playgroud)


Dan*_*ira 6

添加到您的pubspec.yaml。这对我有用。

dependency_overrides:
   flutter_math_fork: ^0.5.0
   provider: ^6.0.2
Run Code Online (Sandbox Code Playgroud)


Sha*_*put 5

首先尝试更新您的flutter_math_fork to 0.6.0 but in my case

将 flutter 版本更新到 2.8.1 后,我遇到了同样的错误,并且无法更新flutter_math_fork到最新版本,因为我正在使用Provider version 5.0.0and flutter_math_formrequire provider version 6.0.0+。因此,在升级其他库之前,您可以修改/lib/src/widgets/selectable.dart此文件。添加这一行。

 @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);
  }
}
Run Code Online (Sandbox Code Playgroud)

删除这个方法

 @override  
  void bringIntoView(TextPosition position) {}  
  @override 
  void userUpdateTextEditingValue(  
      TextEditingValue value, SelectionChangedCause cause) {}   
}
Run Code Online (Sandbox Code Playgroud)

或者直接复制粘贴这个