【Flutter 解決済】The method ‘File.create’ has fewer named arguments than those of overridden method ‘File.create’.のエラー

状況

2ヶ月くらい放置のアプリを久しぶりに更新しようとしたら、「The method ‘File.create’ has fewer named arguments than those of overridden method ‘File.create’.」というエラーが発生して、起動できなかった。
その間にFlutterのバージョンが「 3.7.1」に上がっている。

解決方法

以下を実施して、dependenciesにfileを追加して実行したら、動作するようになった。
実施後、fileを消しても動作する。

 flutter pub add  file
 flutter pub get

考察

fileのパッケージだけ更新されてなかったけど、dependenciesにfileを追加したことで、強制的に更新できたのかな。

参考

dart pub upgrade

エラー全文

Launching lib\terminal on Pixel 4a 5G in debug mode...
Running Gradle task 'assembleDebug'...
/C:/Users/sakura/AppData/Roaming/Pub/Cache/hosted/pub.dev/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'.
  Future<File> create({bool recursive = false});
               ^
org-dartlang-sdk:///third_party/dart/sdk/lib/io/file.dart:232:16: Context: This is the overridden method ('create').
  Future<File> create({bool recursive = false, bool exclusive = false});
               ^
/C:/Users/sakura/AppData/Roaming/Pub/Cache/hosted/pub.dev/file-6.1.2/lib/src/interface/file.dart:15:16: Error: The method 'File.create' doesn't have the named parameter 'exclusive' of overridden method 'File.create'.
  Future<File> create({bool recursive = false});
               ^
org-dartlang-sdk:///third_party/dart/sdk/lib/io/file.dart:232:16: Context: This is the overridden method ('create').
  Future<File> create({bool recursive = false, bool exclusive = false});
               ^
/C:/Users/sakura/AppData/Roaming/Pub/Cache/hosted/pub.dev/file-6.1.2/lib/src/forwarding/forwarding_file.dart:22:8: Error: The method 'ForwardingFile.createSync' has fewer named arguments than those of overridden method 'File.createSync'.
  void createSync({bool recursive = false}) =>
       ^
org-dartlang-sdk:///third_party/dart/sdk/lib/io/file.dart:248:8: Context: This is the overridden method ('createSync').
  void createSync({bool recursive = false, bool exclusive = false});
       ^
/C:/Users/sakura/AppData/Roaming/Pub/Cache/hosted/pub.dev/file-6.1.2/lib/src/forwarding/forwarding_file.dart:22:8: Error: The method 'ForwardingFile.createSync' doesn't have the named parameter 'exclusive' of overridden method 'File.createSync'.
  void createSync({bool recursive = false}) =>
       ^
org-dartlang-sdk:///third_party/dart/sdk/lib/io/file.dart:248:8: Context: This is the overridden method ('createSync').
  void createSync({bool recursive = false, bool exclusive = false});
       ^
Target kernel_snapshot failed: Exception


FAILURE: Build failed with an exception.

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

* 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 2m 47s
Exception: Gradle task assembleDebug failed with exit code 1