已解决:Error: The non-abstract clas
2022-01-25 本文已影响0人
Nur__
Flutter 版本更新后报错了,(还好有个stackoverflow,这里有好多解决方案,我也是用他们的方式来解决了)
报错内容
../../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
这是因为我用的provider版本是5.0;(不能使用6.0,因为本项目的sdk版本不支持),如果你的sdk>=2.0的话你改一下provider的版本,可能会解决;
解决方式
- provider 版本升级到6.x
- flutter_math_fork 版本升级到 ^0.5.0
- 第三种方式 原文
截屏2022-01-25 下午2.41.56.png
首先尝试将您更新flutter_math_fork到 0.6.0 但在我的情况下
将颤振版本更新到 2.8.1 后我遇到了同样的错误,我无法更新flutter_math_fork到最新版本,因为我正在使用Provider version 5.0.0和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);
}
去掉这个方法
@override
void bringIntoView(TextPosition position) {}
@override
void userUpdateTextEditingValue(
TextEditingValue value, SelectionChangedCause cause) {}
}