Error: Cannot run with sound null safety, because the following dependencies

 ** BUILD FAILED **
Xcode's output:
↳
    Writing result bundle at path:
    	/var/folders/qq/mk6p4bl91bb3n5qcxf33zn3h0000gn/T/flutter_tools.k99OR8/flutter_ios_build_temp_dir6qnCBH/temporary_xcresult_bundle
    Error: Cannot run with sound null safety, because the following dependencies
    don't support null safety:
     - package:provide
     - package:flutter_screenutil
    For solutions, see https://dart.dev/go/unsound-null-safety
: Error: The method 'inheritFromWidgetOfExactType' isn't defined for the class 'BuildContext'.
../…/lib/provide.dart:570
- 'BuildContext' is from 'package:flutter/src/widgets/framework.dart' ('../../flutter/packages/flutter/lib/src/widgets/framework.dart').
package:flutter/…/widgets/framework.dart:1
    Try correcting the name to the name of an existing method, or defining a method named 'inheritFromWidgetOfExactType'.
        final widget = context.inheritFromWidgetOfExactType(_InheritedProviders);
                               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
    Failed to package /Users/wangguibin/Desktop/my_flutter_demo.
    Command PhaseScriptExecution failed with a nonzero exit code

升級flutter版本到3.0.0之後,發現之前寫的demo跑不起來了, 原因是新版dart引入null safety的玩意兒 類似swift的option ?
要麼升級依賴庫的新版本,要麼就加編譯參數忽略一下即可

flutter clean
flutter run --no-sound-null-safety
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章