简体   繁体   English

使用 Getx 小部件-Flutter 运行时显示错误

[英]showing Error while running using Getx widget-Flutter

This error occurs only when I use get package.仅当我使用 get package 时才会出现此错误。 To Solve this problem, I deleted get folder from the.pub-cache/hosted/pub.dartlang.org destination and again imported it but nothing happened.为了解决这个问题,我从 .pub-cache/hosted/pub.dartlang.org 目的地删除了 get 文件夹,然后再次导入它,但什么也没发生。

Launching lib\main.dart on sdk gphone x86 arm in debug mode...
Running Gradle task 'assembleDebug'...

/D:/Flutter/.pub-cache/hosted/pub.dartlang.org/get-3.25.4/lib/
get_navigation/src/root/get_cupertino_app.dart:121:9: 
Error: Type 'RouteInformationProvider' not found.

final RouteInformationProvider routeInformationProvider;
^^^^^^^^^^^^^^^^^^^^^^^^

/D:/Flutter/.pub-cache/hosted/pub.dartlang.org/get-3.25.4/lib/
get_navigation/src/root/get_cupertino_app.dart:122:9: Error: Type
'RouteInformationParser' not found.
final RouteInformationParser<Object> routeInformationParser;
^^^^^^^^^^^^^^^^^^^^^^

/D:/Flutter/.pub-cache/hosted/pub.dartlang.org/get-3.25.4/lib/
get_navigation/src/root/get_cupertino_app.dart:122:9: Error:
Expected 0 type arguments.
final RouteInformationParser<Object> routeInformationParser;
^

/D:/Flutter/.pub-cache/hosted/pub.dartlang.org/get-3.25.4/lib/
get_navigation/src/root/get_cupertino_app.dart:123:9: Error: Type
'RouterDelegate' not found.
final RouterDelegate<Object> routerDelegate;
^^^^^^^^^^^^^^

/D:/Flutter/.pub-cache/hosted/pub.dartlang.org/get-3.25.4/lib/
get_navigation/src/root/get_cupertino_app.dart:123:9: Error:
Expected 0 type arguments.
final RouterDelegate<Object> routerDelegate;
^


/D:/Flutter/.pub-cache/hosted/pub.dartlang.org/get-3.25.4/lib/
get_navigation/src/root/get_material_app.dart:130:9: Error:
Expected 0 type arguments.
final RouteInformationParser<Object> routeInformationParser;
^^^^^^^^^^^^^^
/D:/Flutter/.pub-cache/hosted/pub.dartlang.org/get-3.25.4/lib/
get_navigation/src/root/get_material_app.dart:132:9: Error: '
BackButtonDispatcher' isn't a type.
final BackButtonDispatcher backButtonDispatcher;
^^^^^^^^^^^^^^^^^^^^
/D:/Flutter/.pub-cache/hosted/pub.dartlang.org/get-3.25.4/lib/
get_navigation/src/root/get_material_app.dart:245:25: Error:
Method not found: 'MaterialApp.router'.
? MaterialApp.router(
^^^^^^
FAILURE: Build failed with an exception.
* Where:
Script 'D:\Flutter\packages\flutter_tools\gradle\flutter.gradle'
line: 896
* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'D:\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 22s
Exception: Gradle task assembleDebug failed with exit code 1

I Used many other packages but the error occurred only when using get package.我使用了许多其他软件包,但仅在使用 get package 时才发生错误。

open your android studio terminal打开你的 android 工作室终端

1 - clean your project 1 - 清理你的项目

flutter clean 

2 - change flutter channel to stable 2 - 将 flutter 通道更改为稳定

Flutter channels:
  master
  dev
  beta
* stable

make sure you are on a stable channel确保您在稳定的频道上

3 - now you need to make upgrade flutter upgrade (on the terminal) 3 - 现在您需要升级 flutter 升级(在终端上)

flutter upgrade 

output output

Flutter is already up to date on channel stable
Flutter 2.0.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision c5a4b4029c (2 days ago) • 2021-03-04 09:47:48 -0800
Engine • revision 40441def69
Tools • Dart 2.12.0

4 - make clean again 4 - 再次清洁

flutter clean 

if you on flutter 2 then all is well:)如果你在 flutter 2 上,那么一切都很好:)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM