Improve 'flutter downgrade' error message (#154434)

`flutter downgrade` fails if you haven't used `flutter upgrade`:

```
$ flutter downgrade
There is no previously recorded version for channel "stable".
```

It's not clear what actions a user should take from this error message. Here's the new error message:

```
$ flutter downgrade
It looks like you haven't run "flutter upgrade" on channel "stable".

"flutter downgrade" undoes the last "flutter upgrade".

To switch to a specific Flutter version, see: https://flutter.dev/to/switch-flutter-version
```

Depends on https://github.com/flutter/website/pull/11098
This commit is contained in:
Loïc Sharma
2024-09-04 15:06:31 -07:00
committed by GitHub
parent 6abef22251
commit 3bda455f4e
2 changed files with 37 additions and 11 deletions

View File

@@ -77,10 +77,16 @@ void main() {
logger: bufferLogger,
);
expect(createTestCommandRunner(command).run(const <String>['downgrade']),
throwsToolExit(message:
'There is no previously recorded version for channel "beta".\n'
'Channel "master" was previously on: v1.2.3.'
expect(
createTestCommandRunner(command).run(const <String>['downgrade']),
throwsToolExit(message: '''
It looks like you haven't run "flutter upgrade" on channel "beta".
"flutter downgrade" undoes the last "flutter upgrade".
To switch to a specific Flutter version, see: https://flutter.dev/to/switch-flutter-version
Channel "master" was previously on: v1.2.3.''',
),
);
});