⚠️

(初心者向け)flutter upgradeエラーによる解決方法

2023/04/17に公開

1. 問題事象

下記の通りflutter doctor実行により、新しいVerがあると案内される。

┌─────────────────────────────────────────────────────────┐
│ A new version of Flutter is available!                  │
│                                                         │
│ To update to the latest version, run "flutter upgrade". │
└─────────────────────────────────────────────────────────┘

上記コマンドを実行してもエラーが生じる。

% flutter upgrade
Your flutter checkout has local changes that would be erased by upgrading. If
you want to keep these changes, it is recommended that you stash them via "git
stash" or else commit the changes to a local branch. If it is okay to remove
local changes, then re-run this command with "--force".

変更履歴があり、git stashを実行することで一時的に保存することができるものの、特に現時点の変更履歴を残す必要がない場合、以下の通り、強制的にアップグレードをすることも可能。

flutter upgrade --force

Discussion