0

在我的项目中,我使用了 GetX v4.6.1。当它在调试模式下构建时,我遇到了这个错误

/C:/Users/ALIF/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/get-4.6.1/lib/get_navigation/src/root/get_material_app.dart:275:17: Error: No named parameter with the name 'useInheritedMediaQuery'.
                useInheritedMediaQuery: useInheritedMediaQuery,         
                ^^^^^^^^^^^^^^^^^^^^^^                                  
/C:/src/flutter/packages/flutter/lib/src/material/app.dart:217:9: Context: Found this candidate, but the arguments don't match.
  const MaterialApp.router({                                            
/C:/Users/ALIF/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/get-4.6.1/lib/get_navigation/src/root/get_material_app.dart:322:17: Error: No named parameter with the name 'useInheritedMediaQuery'.                                                                                                  useInheritedMediaQuery: useInheritedMediaQuery,
                ^^^^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/material/app.dart:166:9: Context: Found this candidate, but the arguments don't match.
  const MaterialApp({
        ^^^^^^^^^^^
/C:/Users/ALIF/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/get-4.6.1/lib/get_navigation/src/root/get_cupertino_app.dart:252:17: Error: No named parameter with the name 'useInheritedMediaQuery'.                                                                                                 useInheritedMediaQuery: useInheritedMediaQuery,
                ^^^^^^^^^^^^^^^^^^^^^^
/C:/src/flutter/packages/flutter/lib/src/cupertino/app.dart:189:9: Context: Found this candidate, but the arguments don't match.
  const CupertinoApp.router({                                           
        ^^^^^^^^^^^^^^^^^^^                                             
/C:/Users/ALIF/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/get-4.6.1/lib/get_navigation/src/root/get_cupertino_app.dart:292:17: Error: No named parameter with the name 'useInheritedMediaQuery'.
                useInheritedMediaQuery: useInheritedMediaQuery,         
                ^^^^^^^^^^^^^^^^^^^^^^                                  
/C:/src/flutter/packages/flutter/lib/src/cupertino/app.dart:145:9: Context: Found this candidate, but the arguments don't match.
  const CupertinoApp({                                                  
        ^^^^^^^^^^^^                                                    
                                                                        
                                                                        
FAILURE: Build failed with an exception.                                
                                                                        
* Where:                                                                
Script 'C:\src\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1035

* What went wrong:
Execution failed for task ':app:compileFlutterBuildDebug'.
> Process 'command 'C:\src\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 1m 23s                                                  
Running Gradle task 'assembleDebug'...                                  
Running Gradle task 'assembleDebug'... Done                        87.9s
Exception: Gradle task assembleDebug failed with exit code 1

我也已经遵循了这些参考资料,但仍未解决问题。我第一次遇到这个问题是当我的项目上的 MyApp 小部件(根)将从 MaterialApp 更改为 GetMaterialApp 时。

4

5 回答 5

2

pubspec.yaml使用获取包如下:

get: 4.6.1

# 不要使用 ^

于 2022-01-09T14:42:17.490 回答
1

请使用 GetMaterialApp 包装。

  return GetMaterialApp(
      debugShowCheckedModeBanner: false,
      theme: appTheme(),
      getPages: AppRoutes.getAppRoutes(),
      initialRoute: AppRoutes.INITIAL,
    );
于 2022-01-01T10:05:05.223 回答
0

为我解决了!

如果使用如下:

  get: ^4.6.1

替换为:

  get: 4.5.1

最后在终端中写:

flutter clean
flutter pub get
于 2022-02-22T12:21:51.853 回答
0

与您遇到的类似的构建任务问题通常可以通过运行flutter clean以清除项目的构建缓存并运行flutter pub get以获取项目的 pubspec.yaml 中配置的项目依赖项来解决

如果您的 pub 缓存中的包损坏,您可以使用flutter pub cache repair命令对系统缓存中的所有托管和 git 包执行全新的重新安装。

于 2022-01-26T14:24:05.653 回答
0

我有同样的问题。我通过将 GetX 版本减少为:

#In pubspec.yaml use get package like below :

get: 4.5.1

这对我不起作用:

#In pubspec.yaml use get package like below :

get: 4.6.1
于 2022-02-09T07:12:39.120 回答