# Upgrade Flutter

> Learn how to upgrade Flutter and switch to another channel.



No matter which one of the Flutter release channels
you follow, you can use the `flutter` command to upgrade your
Flutter SDK or the packages that your app depends on.

<a id="upgrading-the-flutter-sdk" aria-hidden="true"></a>

## Upgrade the Flutter SDK

To update the Flutter SDK use the `flutter upgrade` command:

```console
$ flutter upgrade
```

This command gets the most recent version of the Flutter SDK
that's available on your current Flutter channel.

If you are using the **stable** channel
and want an even more recent version of the Flutter SDK,
switch to the **beta** channel using `flutter channel beta`,
and then run `flutter upgrade`.

<a id="keep-informed" aria-hidden="true"></a>

### Keep informed

We publish [migration guides][] for known breaking changes.

We send announcements regarding these changes to the
[Flutter announcements mailing list][flutter-announce].

To avoid being broken by future versions of Flutter,
consider submitting your tests to our [test registry][].


## Switching Flutter channels

Flutter has two release channels:
**stable** and **beta**.

### The **stable** channel

We recommend the **stable** channel for new users
and for production app releases.
The team updates this channel about every three months.
The channel might receive occasional hot fixes
for high-severity or high-impact issues.

The continuous integration for the Flutter team's plugins and packages
includes testing against the latest **stable** release.

The latest documentation for the **stable** branch
is at: <https://api.flutter.dev>

### The **beta** channel

The **beta** channel has the latest stable release.
This is the most recent version of Flutter that we have heavily tested.
This channel has passed all our public testing,
has been verified against test suites for Google products that use Flutter,
and has been vetted against [contributed private test suites][test registry].
The **beta** channel receives regular hot fixes
to address newly discovered important issues.

The **beta** channel is essentially the same as the **stable** channel
but updated monthly instead of quarterly.
Indeed, when the **stable** channel is updated,
it is updated to the latest **beta** release.

### Other channels

We currently have one other channel, **main** (previously known as **master**).
People who [contribute to Flutter][] use this channel.

This channel is not as thoroughly tested as
the **beta** and **stable** channels.

We do not recommend using this channel as
it is more likely to contain serious regressions.

The latest documentation for the **main** branch
is at: <https://main-api.flutter.dev>

<a id="changing-channels" aria-hidden="true"></a>

### Change channels

To view your current channel, use the following command:

```console
$ flutter channel
```

To change to another channel, use `flutter channel <channel-name>`.
Once you've changed your channel, use `flutter upgrade`
to download the latest Flutter SDK and dependent packages for that channel.
For example:

```console
$ flutter channel beta
$ flutter upgrade
```

<a id="switching-to-a-specific-flutter-version" aria-hidden="true"></a>

## Switch to a specific Flutter version

To switch to a specific Flutter version:

1. Find your desired **Flutter version** on the [Flutter SDK archive][].

1. Navigate to the Flutter SDK:

   ```console
   $ cd /path/to/flutter
   ```

   :::tip
   You can find the Flutter SDK's path using `flutter doctor --verbose`.
   :::

1. Use `git checkout` to switch to your desired **Flutter version**:

   ```console
   $ git checkout <Flutter version>
   ```

<a id="upgrading-packages" aria-hidden="true"></a>

## Upgrade packages

If you've modified your `pubspec.yaml` file, or you want to update
only the packages that your app depends upon
(instead of both the packages and Flutter itself),
then use one of the `flutter pub` commands.

To update to the _latest compatible versions_ of
all the dependencies listed in the `pubspec.yaml` file,
use the `upgrade` command:

```console
$ flutter pub upgrade
```

To update to the _latest possible version_ of
all the dependencies listed in the `pubspec.yaml` file,
use the `upgrade --major-versions` command:

```console
$ flutter pub upgrade --major-versions
```

This also automatically update the constraints
in the `pubspec.yaml` file.

To identify out-of-date package dependencies and get advice
on how to update them, use the `outdated` command. For details, see
the Dart [`pub outdated` documentation](https://dart.dev/tools/pub/cmd/pub-outdated).

```console
$ flutter pub outdated
```

## Troubleshooting

### Windows: "Filename too long" error

When running `flutter upgrade` on Windows,
you might encounter an error like the following:

```text
error: unable to create file ...: Filename too long
```

This occurs because the path to a file in the Flutter SDK exceeds the default
maximum path length limit on Windows.

To resolve this issue, consider installing the Flutter SDK
at a shorter path. For example, install Flutter at
`C:\Flutter` instead of something longer like
`C:\Users\<user name>\Documents\flutter`.

Otherwise, do the following:

1. Enable long paths support in Git:

   ```console
   $ git config --system core.longpaths true
   ```
   
   If the command fails with a permission error,
   try running your terminal as an administrator.

1. Enable long paths in Windows:
   
   ```console
   New-ItemProperty -Path "HKLM:\SYSTEM\CurrentControlSet\Control\FileSystem" -Name "LongPathsEnabled" -Value 1 -PropertyType DWORD -Force
   ```
   
   This command requires administrator privileges.

[Flutter SDK archive]: /install/archive
[flutter-announce]: https://groups.google.com/forum/#!forum/flutter-announce
[pubspec.yaml]: https://dart.dev/tools/pub/pubspec
[test registry]: https://github.com/flutter/tests
[contribute to Flutter]: https://github.com/flutter/flutter/blob/main/CONTRIBUTING.md
[migration guides]: /release/breaking-changes

