我的项目在1.10.0版本上运行良好,我已将flutter升级到新的1.12版,并且出现以下错误
编译器消息:
../../../AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/flutter_platform_widgets-0.20.2/lib/src/platform_scaffold.dart:229:38: Error: The getter 'fullObstruction' isn't defined for the class 'ObstructingPreferredSizeWidget'.
- 'ObstructingPreferredSizeWidget' is from 'package:flutter/src/cupertino/page_scaffold.dart' ('/C:/src/flutter/packages/flutter/lib/src/cupertino/page_scaffold.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'fullObstruction'.
final obstruct = navigationBar.fullObstruction == null ||
^^^^^^^^^^^^^^^
../../../AppData/Roaming/Pub/Cache/hosted/pub.dartlang.org/flutter_platform_widgets-0.20.2/lib/src/platform_scaffold.dart:230:25: Error: The getter 'fullObstruction' isn't defined for the class 'ObstructingPreferredSizeWidget'.
- 'ObstructingPreferredSizeWidget' is from 'package:flutter/src/cupertino/page_scaffold.dart' ('/C:/src/flutter/packages/flutter/lib/src/cupertino/page_scaffold.dart').
Try correcting the name to the name of an existing getter, or defining a getter or field named 'fullObstruction'.
navigationBar.fullObstruction;
^^^^^^^^^^^^^^^
目标kernel_snapshot失败:异常:创建快照时出错:null 构建失败。
再次将Flutter降级为1.10,该项目可以正常运行,但我需要升级到适用于webrtc库的1.12版本。有人可以帮助解决这个问题吗?
答案 0 :(得分:2)
对于那些遇到此问题的人,我在这里提供了解决方案。这个问题花了我2天的时间,我一直不停地跳动,为什么即使我升级到Flutter v1.12.13 + hotfix.5-stable.zip的稳定版本,flutter包仍然显示错误?
解决方案: 上面的问题说,对于文件CupertinoPageScaffold.dart中的ObstructingPreferredSizeWidget类未定义fullObstruction。因此,我将文件放在了flutter包中的记事本中。原始路径是C:\ src2 \ flutter \ packages \ flutter \ lib \ src \ cupertino,src2是我的flutter软件包所在的文件夹。
在该文件中,我看到一个变量在较新版本中进行了更改,而不是在之前的变量下为fullObstruction,而是更改为bool shouldFullyObstruct(BuildContext context);在较新的版本中。
abstract class ObstructingPreferredSizeWidget extends PreferredSizeWidget {
/// If true, this widget fully obstructs widgets behind it by the specified
/// size.
///
/// If false, this widget partially obstructs.
bool shouldFullyObstruct(BuildContext context);
}
然后我检查此错误发生在哪个文件中, C:\ src2 \ flutter.pub-cache \ hosted \ pub.dartlang.org \ flutter_platform_widgets-0.20.2 \ lib \ src \ platform-scaffold.dart
此行之前使用的是不赞成使用的变量fullObstruction,我用新变量替换了该变量并解决了问题,并且我的项目像以前一样正常工作。
final obstruct = navigationBar.shouldFullyObstruct(context)== null || navigationBar.shouldFullyObstruct(context);
希望这对某人有帮助。