Flutter 版本更新后報錯了胯舷,(還好有個stackoverflow芭届,這里有好多解決方案瘟仿,我也是用他們的方式來解決了)
報錯內(nèi)容
../../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
這是因?yàn)槲矣玫膒rovider版本是5.0鹃锈;(不能使用6.0拌汇,因?yàn)楸卷椖康膕dk版本不支持),如果你的sdk>=2.0的話你改一下provider的版本谱净,可能會解決窑邦;
解決方式
- provider 版本升級到6.x
- flutter_math_fork 版本升級到 ^0.5.0
- 第三種方式 原文
首先嘗試將您更新flutter_math_fork到 0.6.0 但在我的情況下
將顫振版本更新到 2.8.1 后我遇到了同樣的錯誤,我無法更新flutter_math_fork到最新版本岳遥,因?yàn)槲艺谑褂肞rovider 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) {}
}