我想解决Flutter App中build失败的问题
I want to solve the failure of build in Flutter App
在构建一些像 flutter_form_builder,flutter_chips_input
这样的第 3 方包时,services
包也会抛出错误,导致构建失败,我认为这是包版本崩溃问题....但是,我无法解决这个问题....
我该如何解决?
下面是错误代码。
谢谢。
错误代码
../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_form_builder-3.7.2/lib/src/fields/form_builder_range_slider.dart:21:9: Error: Type 'RangeSemanticFormatterCallback' not found.
final RangeSemanticFormatterCallback semanticFormatterCallback;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_chips_input-1.6.1/lib/src/chips_input.dart:62:7: Error: The non-abstract class 'ChipsInputState' is missing implementations for these members:
- TextInputClient.currentAutofillScope
- TextInputClient.currentTextEditingValue
- TextInputClient.performPrivateCommand
- TextInputClient.showAutocorrectionPromptRect
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 ChipsInputState<T> extends State<ChipsInput<T>>
^^^^^^^^^^^^^^^
../flutter/packages/flutter/lib/src/services/text_input.dart:805:22: Context: 'TextInputClient.currentAutofillScope' is defined here.
AutofillScope? get currentAutofillScope;
^^^^^^^^^^^^^^^^^^^^
../flutter/packages/flutter/lib/src/services/text_input.dart:793:25: Context: 'TextInputClient.currentTextEditingValue' is defined here.
TextEditingValue? get currentTextEditingValue;
^^^^^^^^^^^^^^^^^^^^^^^
../flutter/packages/flutter/lib/src/services/text_input.dart:814:8: Context: 'TextInputClient.performPrivateCommand' is defined here.
void performPrivateCommand(String action, Map<String, dynamic> data);
^^^^^^^^^^^^^^^^^^^^^
../flutter/packages/flutter/lib/src/services/text_input.dart:823:8: Context: 'TextInputClient.showAutocorrectionPromptRect' is defined here.
void showAutocorrectionPromptRect(int start, int end);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
../flutter/.pub-cache/hosted/pub.dartlang.org/flushbar-1.9.1/lib/flushbar_route.dart:273:8: Error: The method 'FlushbarRoute.install' has more required arguments than those of overridden method 'OverlayRoute.install'.
void install(OverlayEntry insertionPoint) {
^
../flutter/packages/flutter/lib/src/widgets/routes.dart:46:8: Context: This is the overridden method ('install').
void install() {
^
../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_form_builder-3.7.2/lib/src/fields/form_builder_range_slider.dart:21:9: Error: 'RangeSemanticFormatterCallback' isn't a type.
final RangeSemanticFormatterCallback semanticFormatterCallback;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
../flutter/.pub-cache/hosted/pub.dartlang.org/flushbar-1.9.1/lib/flushbar_route.dart:281:18: Error: Too many positional arguments: 0 allowed, but 1 found.
Try removing the extra positional arguments.
super.install(insertionPoint);
^
FAILURE: Build failed with an exception.
* Where:
Script '/Users/gabriel/Git/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 900
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command '/Users/gabriel/Git/flutter/bin/flutter'' 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 32s
##############解决方案###############
出现这种情况是因为选择了错误的包版本....
所以,我尝试更改“flutter_form_builder”的版本!
我解决了这个问题!
删除 pubspec.lock
、删除 podfile.lock
和 运行
cd ios && pod repo update && cd .. && flutter clean && flutter pub get
这是因为 flutter_form_builder 与您的 flutter 版本不兼容。根据flutter_form_builder的github页面提示,您需要根据自己的flutter版本选择插件。
来自 github 页面:
For Flutter 1.17.x, use version 3.12.x
For Flutter 1.20.x, use version 3.13.x
For Flutter 1.22.X, use version 3.14.x
您必须在 pubspec.yaml
中输入正确的版本号
在构建一些像 flutter_form_builder,flutter_chips_input
这样的第 3 方包时,services
包也会抛出错误,导致构建失败,我认为这是包版本崩溃问题....但是,我无法解决这个问题....
我该如何解决?
下面是错误代码。
谢谢。
错误代码
../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_form_builder-3.7.2/lib/src/fields/form_builder_range_slider.dart:21:9: Error: Type 'RangeSemanticFormatterCallback' not found.
final RangeSemanticFormatterCallback semanticFormatterCallback;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_chips_input-1.6.1/lib/src/chips_input.dart:62:7: Error: The non-abstract class 'ChipsInputState' is missing implementations for these members:
- TextInputClient.currentAutofillScope
- TextInputClient.currentTextEditingValue
- TextInputClient.performPrivateCommand
- TextInputClient.showAutocorrectionPromptRect
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 ChipsInputState<T> extends State<ChipsInput<T>>
^^^^^^^^^^^^^^^
../flutter/packages/flutter/lib/src/services/text_input.dart:805:22: Context: 'TextInputClient.currentAutofillScope' is defined here.
AutofillScope? get currentAutofillScope;
^^^^^^^^^^^^^^^^^^^^
../flutter/packages/flutter/lib/src/services/text_input.dart:793:25: Context: 'TextInputClient.currentTextEditingValue' is defined here.
TextEditingValue? get currentTextEditingValue;
^^^^^^^^^^^^^^^^^^^^^^^
../flutter/packages/flutter/lib/src/services/text_input.dart:814:8: Context: 'TextInputClient.performPrivateCommand' is defined here.
void performPrivateCommand(String action, Map<String, dynamic> data);
^^^^^^^^^^^^^^^^^^^^^
../flutter/packages/flutter/lib/src/services/text_input.dart:823:8: Context: 'TextInputClient.showAutocorrectionPromptRect' is defined here.
void showAutocorrectionPromptRect(int start, int end);
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
../flutter/.pub-cache/hosted/pub.dartlang.org/flushbar-1.9.1/lib/flushbar_route.dart:273:8: Error: The method 'FlushbarRoute.install' has more required arguments than those of overridden method 'OverlayRoute.install'.
void install(OverlayEntry insertionPoint) {
^
../flutter/packages/flutter/lib/src/widgets/routes.dart:46:8: Context: This is the overridden method ('install').
void install() {
^
../flutter/.pub-cache/hosted/pub.dartlang.org/flutter_form_builder-3.7.2/lib/src/fields/form_builder_range_slider.dart:21:9: Error: 'RangeSemanticFormatterCallback' isn't a type.
final RangeSemanticFormatterCallback semanticFormatterCallback;
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
../flutter/.pub-cache/hosted/pub.dartlang.org/flushbar-1.9.1/lib/flushbar_route.dart:281:18: Error: Too many positional arguments: 0 allowed, but 1 found.
Try removing the extra positional arguments.
super.install(insertionPoint);
^
FAILURE: Build failed with an exception.
* Where:
Script '/Users/gabriel/Git/flutter/packages/flutter_tools/gradle/flutter.gradle' line: 900
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command '/Users/gabriel/Git/flutter/bin/flutter'' 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 32s
##############解决方案###############
出现这种情况是因为选择了错误的包版本.... 所以,我尝试更改“flutter_form_builder”的版本! 我解决了这个问题!
删除 pubspec.lock
、删除 podfile.lock
和 运行
cd ios && pod repo update && cd .. && flutter clean && flutter pub get
这是因为 flutter_form_builder 与您的 flutter 版本不兼容。根据flutter_form_builder的github页面提示,您需要根据自己的flutter版本选择插件。
来自 github 页面:
For Flutter 1.17.x, use version 3.12.x
For Flutter 1.20.x, use version 3.13.x
For Flutter 1.22.X, use version 3.14.x
您必须在 pubspec.yaml
中输入正确的版本号