メソッド 'File.create' の名前付き引数は、オーバーライドされたメソッドの名前付き引数よりも少ないです

問題の説明

Flutter SDK を 3.7.9 に更新した後、プロジェクトを実行すると次のエラー メッセージが表示されます。

Could not build the precompiled application for the device.
Error (Xcode): ../../../.pub-cache/hosted/pub.flutter-io.cn/file-6.1.2/lib/src/interface/file.dart:15:16: Error: The method 'File.create' has fewer named arguments than those of overridden method 'File.create'.


Error launching application on iPhone.

解決

エラー メッセージによると、特定のライブラリは Googlefileライブラリの 6.1.2 バージョンに依存しており、File.createメソッドにはいくつかのパラメータが必要です。更新情報をパブに
入力して表示しました。file|dart パッケージ: https://pub.flutter-io.cn/packages/file/changelogご覧のとおり、6.1.3 以降、メソッドは bool 型のパラメーターを追加するため、バージョンをアップグレードするだけで済みます。ライブラリの 6.1.3 以上である可能性があります。file

ファイルライブラリのバージョン更新ログ
createfile

プロジェクト内のライブラリのバージョンを上書きする

最も残酷な方法は、プロジェクト内でライブラリのバージョンを直接pubspec.yaml指定して、コンパイル時にライブラリのバージョンを統一することです。file

name: wiki assit
description: A new Flutter application 

# The following line prevents the package from being accidentally published to
# pub.dev using `pub publish`. This is preferred for private packages.
publish_to: 'none' # Remove this line if you wish to publish to pub.dev

# The following defines the version and build number for your application.
# A version number is three numbers separated by dots, like 1.2.43
# followed by an optional build number separated by a +.
# Both the version and the builder number may be overridden in flutter
# build by specifying --build-name and --build-number, respectively.
# In Android, build-name is used as versionName while build-number used as versionCode.
# Read more about Android versioning at https://developer.android.com/studio/publish/versioning
# In iOS, build-name is used as CFBundleShortVersionString while build-number used as CFBundleVersion.
# Read more about iOS versioning at
# https://developer.apple.com/library/archive/documentation/General/Reference/InfoPlistKeyReference/Articles/CoreFoundationKeys.html
version: 1.2.0+4

environment:
  sdk: ">=2.17.0 <3.0.0"

dependencies:
  flutter:
    sdk: flutter
  flutter_localizations:
    sdk: flutter

  # The following adds the Cupertino Icons font to your application.
  # Use with the CupertinoIcons class for iOS style icons.
  cupertino_icons: ^1.0.2
  # 指定 file 版本,6.1.3及以上就行
  file: ^6.1.4

pubコマンドを使用する

プロジェクト内で直接参照されないため、依存関係は pub コマンドを通じてのみ解決できます。
まず、キャッシュをクリアします。

flutter clean.

次に、次を使用してpub upgrade依存関係を更新します

flutter pub upgrade

依存関係の更新が完了するまで待ち、プロジェクトを再実行して通常どおり実行します。

おすすめ

転載: blog.csdn.net/adojayfan/article/details/129987976