未为类“FlutterView”定义“viewConfiguration”,- 'FlutterView'来自'dart:ui'

nbewdwxp  于 2023-05-30  发布在  Flutter
关注(0)|答案(3)|浏览(518)

我的Flutter项目是:here。当我尝试运行Rahulraj分支中的代码时,我得到以下错误:

/C:/Users/Sanmitha/AppData/Local/Pub/Cache/hosted/pub.dev/flutter_screenutil-5.6.1/lib/src/screen_util.dart:64:16: Error: The getter 'viewConfiguration' isn't defined for the class 'FlutterView'.
 - 'FlutterView' is from 'dart:ui'.
Try correcting the name to the name of an existing getter, or defining a getter or field named 'viewConfiguration'.
    if (window.viewConfiguration.geometry.isEmpty) {
               ^^^^^^^^^^^^^^^^^
Target kernel_snapshot failed: Exception

FAILURE: Build failed with an exception.

* Where:
Script 'C:\flutter\packages\flutter_tools\gradle\flutter.gradle' line: 1153

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

谁能帮我解决这个问题???求你了?

ktecyv1j

ktecyv1j1#

更新:flutter_screenutil更新了,请使用实际版本(5.7.0+)。
=原始答案=======================================================================================================================================================================================================================================================
问题出现在最后一次Flutter更新中:https://github.com/flutter/flutter/issues/121742.中的FlutterView. viewConfiguration属性被删除,但它在flutter_screenutil库中使用。
可能的解决方案:

  • 回滚到Flutter的任何以前版本
  • 从flutter_screenutil的分支链接这个库,在那里这个问题被修复了(只是暂时的解决方案!),在flutter_screenutil更新后立即返回依赖项):
flutter_screenutil:
    git:
      url: https://github.com/dmakeev/flutter_screenutil
      ref: fix-463

一般建议使用稳定Flutter通道而不是主通道。

4dc9hkyq

4dc9hkyq2#

此错误发生在Flutter的最新版本(3.9.0-1.0)(2023年3月)中。可能的解决方案是,
1.使用Flutter Version Manager(fvm)https://pub.dev/packages/fvm降级项目中flutter的版本。flutter pub global activate fvm
或者.. 2.删除这个软件包flutter_screenutil并使用不同的选项如MediaQuery.
OR.. 3.降级Flutterflutter downgrade v1.17.0

相关问题