Preselect the version when only one version is available (#19)

e.g. Arch Linux only has `latest` available. We can preselect `latest` in this instance.
This commit is contained in:
Dani Llewellyn 2021-11-12 12:21:10 +00:00 committed by GitHub
parent 5ddb7f80e2
commit a8cb368f94
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 11 additions and 3 deletions

View File

@ -37,13 +37,21 @@ class _HomePageButtonGroupState extends State<HomePageButtonGroup> {
text: _selectedOperatingSystem?.name ?? context.t('Select...'),
onPressed: () {
Navigator.of(context)
.push<OperatingSystem>(MaterialPageRoute(fullscreenDialog: true, builder: (context) => const OperatingSystemSelection()))
.push<OperatingSystem>(MaterialPageRoute(
fullscreenDialog: true,
builder: (context) => const OperatingSystemSelection()))
.then((selection) {
if (selection != null) {
setState(() {
_selectedOperatingSystem = selection;
_selectedVersion = null;
_selectedOption = null;
if (selection.versions.length == 1 &&
selection.versions.first.options.length == 1) {
_selectedVersion = selection.versions.first;
_selectedOption = selection.versions.first.options.first;
} else {
_selectedVersion = null;
_selectedOption = null;
}
});
}
});