From 06d303abe8cc83d705eba6f5698a50fb18b83eb2 Mon Sep 17 00:00:00 2001 From: leoafarias Date: Thu, 3 Jun 2021 12:59:01 -0400 Subject: [PATCH] Auto formatting --- lib/main.dart | 2 +- .../components/molecules/delete_dialog.dart | 6 ++-- .../organisms/cleanup_unused_dialog.dart | 4 +-- .../organisms/global_info_dialog.dart | 10 +++--- lib/src/modules/common/app_shell.dart | 4 +-- lib/src/modules/common/atoms/group_tile.dart | 2 +- lib/src/modules/common/constants.dart | 4 +-- lib/src/modules/common/utils/helpers.dart | 4 +-- .../modules/common/utils/scan_directory.dart | 6 ++-- .../fvm/components/fvm_release_actions.dart | 2 +- lib/src/modules/fvm/fvm.provider.dart | 2 +- lib/src/modules/fvm/fvm_queue.provider.dart | 6 ++-- .../components/package_github_info.dart | 6 ++-- lib/src/modules/packages/packages.screen.dart | 2 +- .../projects/components/project_actions.dart | 2 +- .../components/project_list_item.dart | 2 +- .../components/project_release_select.dart | 34 +++++++++---------- .../modules/projects/projects.provider.dart | 8 ++--- lib/src/modules/projects/projects.screen.dart | 2 +- .../modules/projects/projects.service.dart | 2 +- .../modules/sandbox/components/terminal.dart | 4 +-- lib/src/modules/sandbox/sandbox.screen.dart | 18 +++++----- .../scenes/flutter_settings.scene.dart | 6 ++-- .../settings/scenes/fvm_settings.scene.dart | 8 ++--- .../scenes/general_settings.scene.dart | 16 ++++----- lib/src/modules/settings/settings.dto.dart | 24 +++++-------- .../modules/settings/settings.provider.dart | 4 +-- .../updater/components/update_button.dart | 10 +++--- .../updater/components/update_info.dart | 6 ++-- lib/src/modules/updater/updater.service.dart | 8 ++--- lib/src/modules/updater/updater.utils.dart | 6 ++-- lib/src/screens/error_db_screen.dart | 10 +++--- lib/src/theme.dart | 4 +-- 33 files changed, 114 insertions(+), 120 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index cf24952a..75a1c189 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -27,7 +27,7 @@ void main() async { await SettingsService.init(); await ProjectsService.init(); } on FileSystemException { - print("There was an issue opening the DB"); + print('There was an issue opening the DB'); } if (Platform.isWindows || Platform.isLinux || Platform.isMacOS) { diff --git a/lib/src/components/molecules/delete_dialog.dart b/lib/src/components/molecules/delete_dialog.dart index 596aa13e..85758a83 100644 --- a/lib/src/components/molecules/delete_dialog.dart +++ b/lib/src/components/molecules/delete_dialog.dart @@ -13,23 +13,23 @@ void showDeleteDialog( builder: (context) { // return object of type Dialog return AlertDialog( - title: const Text("Are you sure you want to remove?"), + title: const Text('Are you sure you want to remove?'), content: Text('This will remove ${item.name} cache from your system.'), buttonPadding: const EdgeInsets.all(15), actions: [ // usually buttons at the bottom of the dialog TextButton( - child: const Text("Cancel"), onPressed: () { Navigator.of(context).pop(); }, + child: const Text('Cancel'), ), TextButton( - child: const Text("Confirm"), onPressed: () async { Navigator.of(context).pop(); onDelete(); }, + child: const Text('Confirm'), ), ], ); diff --git a/lib/src/components/organisms/cleanup_unused_dialog.dart b/lib/src/components/organisms/cleanup_unused_dialog.dart index 008ac846..b1ef0066 100644 --- a/lib/src/components/organisms/cleanup_unused_dialog.dart +++ b/lib/src/components/organisms/cleanup_unused_dialog.dart @@ -25,13 +25,12 @@ Future cleanupUnusedDialog(BuildContext context) async { actions: [ // usually buttons at the bottom of the dialog TextButton( - child: const Text("Cancel"), onPressed: () { Navigator.of(context).pop(); }, + child: const Text('Cancel'), ), TextButton( - child: const Text("Confirm"), onPressed: () async { final unusedSelected = unusedVersions.where( (element) => selected.containsKey(element.name), @@ -42,6 +41,7 @@ Future cleanupUnusedDialog(BuildContext context) async { Navigator.of(context).pop(); }, + child: const Text('Confirm'), ), ], content: Container( diff --git a/lib/src/components/organisms/global_info_dialog.dart b/lib/src/components/organisms/global_info_dialog.dart index fe19a038..7c0978e1 100644 --- a/lib/src/components/organisms/global_info_dialog.dart +++ b/lib/src/components/organisms/global_info_dialog.dart @@ -18,7 +18,6 @@ Future showGlobalInfoDialog(BuildContext context) async { title: const Heading('Global configuration'), actions: [ TextButton( - child: const Text("OK"), style: ButtonStyle( padding: MaterialStateProperty.resolveWith( (states) => const EdgeInsets.all(20), @@ -26,6 +25,7 @@ Future showGlobalInfoDialog(BuildContext context) async { onPressed: () { Navigator.of(context).pop(); }, + child: const Text('OK'), ), ], content: Container( @@ -34,15 +34,15 @@ Future showGlobalInfoDialog(BuildContext context) async { mainAxisSize: MainAxisSize.min, children: [ const Subheading( - "Flutter PATH is pointing to\n ", + 'Flutter PATH is pointing to\n ', ), - Caption("${configured.currentPath}.\n\n"), + Caption('${configured.currentPath}.\n\n'), !configured.isSetup ? Column( children: [ const Subheading( - "Change the path to\n" - "if you want to Flutter SDK through FVM", + 'Change the path to\n' + 'if you want to Flutter SDK through FVM', ), Row( children: [ diff --git a/lib/src/modules/common/app_shell.dart b/lib/src/modules/common/app_shell.dart index 8b7656af..b49272ad 100644 --- a/lib/src/modules/common/app_shell.dart +++ b/lib/src/modules/common/app_shell.dart @@ -134,7 +134,6 @@ class AppShell extends HookWidget { duration: const Duration(milliseconds: 250), reverse: selectedIndex.value < (navigation.previous.index ?? 0), - child: renderPage(selectedIndex.value), transitionBuilder: ( child, animation, @@ -142,13 +141,14 @@ class AppShell extends HookWidget { ) { return SharedAxisTransition( fillColor: Colors.transparent, - child: child, animation: animation, secondaryAnimation: secondaryAnimation, transitionType: SharedAxisTransitionType.vertical, + child: child, ); }, + child: renderPage(selectedIndex.value), ), ), ], diff --git a/lib/src/modules/common/atoms/group_tile.dart b/lib/src/modules/common/atoms/group_tile.dart index fc23f860..fe330659 100644 --- a/lib/src/modules/common/atoms/group_tile.dart +++ b/lib/src/modules/common/atoms/group_tile.dart @@ -49,12 +49,12 @@ class SkGroupTile extends HookWidget { title: title, leading: leading, trailing: trailing, - children: children, tilePadding: const EdgeInsets.fromLTRB(20, 5, 20, 5), backgroundColor: Colors.white12, onExpansionChanged: (expanded) { isExpanded.value = expanded; }, + children: children, ), ); } diff --git a/lib/src/modules/common/constants.dart b/lib/src/modules/common/constants.dart index 9df5786d..bdd39848 100644 --- a/lib/src/modules/common/constants.dart +++ b/lib/src/modules/common/constants.dart @@ -41,6 +41,6 @@ Map channelDescriptions = { /// Sidekick repository slug final kSidekickRepoSlug = RepositorySlug( - "leoafarias", - "sidekick", + 'leoafarias', + 'sidekick', ); diff --git a/lib/src/modules/common/utils/helpers.dart b/lib/src/modules/common/utils/helpers.dart index 3744f394..e06d48be 100644 --- a/lib/src/modules/common/utils/helpers.dart +++ b/lib/src/modules/common/utils/helpers.dart @@ -16,13 +16,13 @@ extension StringExtension on String { /// Iterable extension extension ExtendedIterable on Iterable { /// Like Iterable.map but callback have index as second argument - Iterable mapIndexed(T f(E e, int i)) { + Iterable mapIndexed(T Function(E e, int i) f) { var i = 0; return map((e) => f(e, i++)); } /// For each with index - void forEachIndexed(void f(E e, int i)) { + void forEachIndexed(void Function(E e, int i) f) { var i = 0; forEach((e) => f(e, i++)); } diff --git a/lib/src/modules/common/utils/scan_directory.dart b/lib/src/modules/common/utils/scan_directory.dart index e898763c..4f8d3a9d 100644 --- a/lib/src/modules/common/utils/scan_directory.dart +++ b/lib/src/modules/common/utils/scan_directory.dart @@ -1,9 +1,11 @@ import 'dart:io'; +import 'package:flutter/material.dart'; + /// Scans [rootDir] for a certain condition Future> scanDirectoryForCondition({ - bool Function(FileSystemEntity) condition, - Directory rootDir, + @required bool Function(FileSystemEntity) condition, + @required Directory rootDir, }) async { assert(condition != null); assert(rootDir != null); diff --git a/lib/src/modules/fvm/components/fvm_release_actions.dart b/lib/src/modules/fvm/components/fvm_release_actions.dart index 99920ff8..610b17c1 100644 --- a/lib/src/modules/fvm/components/fvm_release_actions.dart +++ b/lib/src/modules/fvm/components/fvm_release_actions.dart @@ -119,10 +119,10 @@ class FvmReleaseActions extends StatelessWidget { context.read(fvmQueueProvider.notifier).upgrade(release); } }, - child: const Icon(MdiIcons.dotsVertical), itemBuilder: (context) { return renderMenuOptions(); }, + child: const Icon(MdiIcons.dotsVertical), ); } } diff --git a/lib/src/modules/fvm/fvm.provider.dart b/lib/src/modules/fvm/fvm.provider.dart index 5f63637f..efbe4b30 100644 --- a/lib/src/modules/fvm/fvm.provider.dart +++ b/lib/src/modules/fvm/fvm.provider.dart @@ -86,7 +86,7 @@ class FvmCacheProvider extends StateNotifier> { channels = localVersions.where((item) => item.isChannel).toList(); versions = localVersions.where((item) => item.isChannel == false).toList(); all = [...channels, ...versions]; - _setTotalCacheSize(); + await _setTotalCacheSize(); } CacheVersion getChannel(String name) { diff --git a/lib/src/modules/fvm/fvm_queue.provider.dart b/lib/src/modules/fvm/fvm_queue.provider.dart index 9fa63c9d..edc8bad6 100644 --- a/lib/src/modules/fvm/fvm_queue.provider.dart +++ b/lib/src/modules/fvm/fvm_queue.provider.dart @@ -72,7 +72,7 @@ class FvmQueueState extends StateNotifier { final action = skipSetup ? QueueAction.install : QueueAction.installAndSetup; - _addToQueue(version, action: action); + await _addToQueue(version, action: action); } /// Adds setup action to queue @@ -122,7 +122,7 @@ class FvmQueueState extends StateNotifier { case QueueAction.installAndSetup: await FVMClient.install(item.version.name); await FVMClient.setup(item.version.name); - await notify('Version ${item.version.name} has been installed.'); + notify('Version ${item.version.name} has been installed.'); break; case QueueAction.channelUpgrade: await FVMClient.upgradeChannel(item.version.cache); @@ -158,7 +158,7 @@ class FvmQueueState extends StateNotifier { Future pinVersion(FlutterProject project, String version) async { await FVMClient.pinVersion(project, version); await ref.read(projectsProvider.notifier).reload(project); - await notify('Version $version pinned to ${project.name}'); + notify('Version $version pinned to ${project.name}'); } Future _addToQueue(ReleaseDto version, {QueueAction action}) async { diff --git a/lib/src/modules/packages/components/package_github_info.dart b/lib/src/modules/packages/components/package_github_info.dart index 086e26dc..6826da45 100644 --- a/lib/src/modules/packages/components/package_github_info.dart +++ b/lib/src/modules/packages/components/package_github_info.dart @@ -27,7 +27,7 @@ class PackageGithubInfo extends StatelessWidget { const SizedBox(width: 10), TextButton.icon( onPressed: () { - openLink("${repo.htmlUrl}/stargazers"); + openLink('${repo.htmlUrl}/stargazers'); }, icon: const Icon(Icons.star, size: 15), label: Text(repo.stargazersCount.toString()), @@ -35,7 +35,7 @@ class PackageGithubInfo extends StatelessWidget { const SizedBox(width: 10), TextButton.icon( onPressed: () { - openLink("${repo.htmlUrl}/issues"); + openLink('${repo.htmlUrl}/issues'); }, icon: const Icon(MdiIcons.alertCircleOutline, size: 15), label: Text(repo.openIssuesCount.toString()), @@ -43,7 +43,7 @@ class PackageGithubInfo extends StatelessWidget { const SizedBox(width: 10), TextButton.icon( onPressed: () { - openLink("${repo.htmlUrl}/network/members"); + openLink('${repo.htmlUrl}/network/members'); }, icon: const Icon(MdiIcons.sourceFork, size: 15), label: Text(repo.forksCount.toString()), diff --git a/lib/src/modules/packages/packages.screen.dart b/lib/src/modules/packages/packages.screen.dart index 48f3c625..51adda29 100644 --- a/lib/src/modules/packages/packages.screen.dart +++ b/lib/src/modules/packages/packages.screen.dart @@ -50,7 +50,7 @@ class PackagesScreen extends HookWidget { loading: () => const SkLoadingIndicator(), error: (_, __) => Container( child: const Text( - "There was an issue loading your packages.", + 'There was an issue loading your packages.', ), ), ); diff --git a/lib/src/modules/projects/components/project_actions.dart b/lib/src/modules/projects/components/project_actions.dart index 27fb3408..b0ef3cc9 100644 --- a/lib/src/modules/projects/components/project_actions.dart +++ b/lib/src/modules/projects/components/project_actions.dart @@ -77,10 +77,10 @@ class ProjectActions extends StatelessWidget { ); } }, - child: const Icon(MdiIcons.dotsVertical), itemBuilder: (context) { return renderMenuOptions(); }, + child: const Icon(MdiIcons.dotsVertical), ); } } diff --git a/lib/src/modules/projects/components/project_list_item.dart b/lib/src/modules/projects/components/project_list_item.dart index 21c4bed4..d5dcd6a0 100644 --- a/lib/src/modules/projects/components/project_list_item.dart +++ b/lib/src/modules/projects/components/project_list_item.dart @@ -82,7 +82,7 @@ class ProjectListItem extends HookWidget { children: [ const SizedBox(width: 10), Tooltip( - message: "Open terminal playground", + message: 'Open terminal playground', child: IconButton( iconSize: 20, splashRadius: 20, diff --git a/lib/src/modules/projects/components/project_release_select.dart b/lib/src/modules/projects/components/project_release_select.dart index ac18c35c..87b6e4c1 100644 --- a/lib/src/modules/projects/components/project_release_select.dart +++ b/lib/src/modules/projects/components/project_release_select.dart @@ -29,6 +29,22 @@ class ProjectReleaseSelect extends StatelessWidget { // elevation: 1, padding: EdgeInsets.zero, + onSelected: (version) async { + await context.read(fvmQueueProvider.notifier).pinVersion(project, version); + }, + itemBuilder: (context) { + return releases + .map( + (version) => PopupMenuItem( + value: version.name, + child: Text( + version.name, + style: const TextStyle(fontSize: 12), + ), + ), + ) + .toList(); + }, child: Container( padding: const EdgeInsets.fromLTRB(10, 0, 5, 0), constraints: const BoxConstraints( @@ -45,22 +61,6 @@ class ProjectReleaseSelect extends StatelessWidget { const Icon(MdiIcons.menuDown), ], ), - ), - onSelected: (version) async { - context.read(fvmQueueProvider.notifier).pinVersion(project, version); - }, - itemBuilder: (context) { - return releases - .map( - (version) => PopupMenuItem( - value: version.name, - child: Text( - version.name, - style: const TextStyle(fontSize: 12), - ), - ), - ) - .toList(); - }); + )); } } diff --git a/lib/src/modules/projects/projects.provider.dart b/lib/src/modules/projects/projects.provider.dart index a63991a2..73e19ef2 100644 --- a/lib/src/modules/projects/projects.provider.dart +++ b/lib/src/modules/projects/projects.provider.dart @@ -29,7 +29,7 @@ final projectsPerVersionProvider = Provider((ref) { for (final project in projects) { final version = - project.pinnedVersion != null ? project.pinnedVersion : 'NONE'; + project.pinnedVersion ?? 'NONE'; final versionProjects = list[version]; if (versionProjects != null) { versionProjects.add(project); @@ -84,8 +84,8 @@ class ProjectsStateNotifier extends StateNotifier> { final project = await FVMClient.getProjectByDirectory(Directory(path)); if (project.isFlutterProject) { final ref = ProjectRef(name: path.split('/').last, path: path); - ProjectsService.box.put(path, ref); - load(); + await ProjectsService.box.put(path, ref); + await load(); } else { notify('Not a Flutter project'); } @@ -104,7 +104,7 @@ class ProjectsStateNotifier extends StateNotifier> { if (settings.projectPaths.isNotEmpty) { for (final path in settings.projectPaths) { - ProjectsService.box.put( + await ProjectsService.box.put( path, ProjectRef( name: path.split('/').last, diff --git a/lib/src/modules/projects/projects.screen.dart b/lib/src/modules/projects/projects.screen.dart index 3edfc0c6..bde7bb0b 100644 --- a/lib/src/modules/projects/projects.screen.dart +++ b/lib/src/modules/projects/projects.screen.dart @@ -42,7 +42,7 @@ class ProjectsScreen extends HookWidget { // Operation was canceled by the user. return; } - notifier.addProject(directoryPath); + await notifier.addProject(directoryPath); } useEffect(() { diff --git a/lib/src/modules/projects/projects.service.dart b/lib/src/modules/projects/projects.service.dart index a4e44570..0201ad7a 100644 --- a/lib/src/modules/projects/projects.service.dart +++ b/lib/src/modules/projects/projects.service.dart @@ -47,7 +47,7 @@ class ProjectsService { return FlutterProject.fromProject(project, pubspec); } else { /// If it does not exist should be removed - box.delete(project.projectDir.path); + await box.delete(project.projectDir.path); } }).toList(); diff --git a/lib/src/modules/sandbox/components/terminal.dart b/lib/src/modules/sandbox/components/terminal.dart index 2e75f5e1..617e163f 100644 --- a/lib/src/modules/sandbox/components/terminal.dart +++ b/lib/src/modules/sandbox/components/terminal.dart @@ -108,8 +108,8 @@ class SandboxConsole extends HookWidget { }); } - handleKey(RawKeyEvent key) { - if (key.runtimeType.toString() == "RawKeyDownEvent") { + void handleKey(RawKeyEvent key) { + if (key.runtimeType.toString() == 'RawKeyDownEvent') { if (key.data.logicalKey == LogicalKeyboardKey.arrowUp) { if (terminalState.cmdHistory.length > currentCmdIdx.value) { moveCmdIndex(1); diff --git a/lib/src/modules/sandbox/sandbox.screen.dart b/lib/src/modules/sandbox/sandbox.screen.dart index ff2cac6d..069def3c 100644 --- a/lib/src/modules/sandbox/sandbox.screen.dart +++ b/lib/src/modules/sandbox/sandbox.screen.dart @@ -94,6 +94,9 @@ class SandboxScreen extends HookWidget { return Padding( padding: const EdgeInsets.all(5.0), child: ElevatedButton( + onPressed: () { + selectedRelease.value = version; + }, child: Row( children: [ Padding( @@ -102,15 +105,15 @@ class SandboxScreen extends HookWidget { ), ], ), - onPressed: () { - selectedRelease.value = version; - }, ), ); } return Padding( padding: const EdgeInsets.all(5.0), child: TextButton( + onPressed: () { + selectedRelease.value = version; + }, child: Row( children: [ Padding( @@ -119,9 +122,6 @@ class SandboxScreen extends HookWidget { ), ], ), - onPressed: () { - selectedRelease.value = version; - }, ), ); }, @@ -153,12 +153,12 @@ class SandboxScreen extends HookWidget { color: Colors.deepOrange, ), ), - child: const Text( - 'Cancel', - ), onPressed: () { terminal.endProcess(); }, + child: const Text( + 'Cancel', + ), ) : const OutlinedButton( onPressed: null, diff --git a/lib/src/modules/settings/scenes/flutter_settings.scene.dart b/lib/src/modules/settings/scenes/flutter_settings.scene.dart index ab479c22..034142ff 100644 --- a/lib/src/modules/settings/scenes/flutter_settings.scene.dart +++ b/lib/src/modules/settings/scenes/flutter_settings.scene.dart @@ -60,9 +60,9 @@ class SettingsSectionFlutter extends HookWidget { SwitchListTile( title: const Text('Analytics & Crash Reporting'), subtitle: const Text( - "When a flutter command crashes it attempts" - " to send a crash report to Google in order to help" - " Google contribute improvements to Flutter over time", + 'When a flutter command crashes it attempts' + ' to send a crash report to Google in order to help' + ' Google contribute improvements to Flutter over time', ), value: !settings.flutter.analytics, onChanged: deactivate diff --git a/lib/src/modules/settings/scenes/fvm_settings.scene.dart b/lib/src/modules/settings/scenes/fvm_settings.scene.dart index b752c720..c26297f6 100644 --- a/lib/src/modules/settings/scenes/fvm_settings.scene.dart +++ b/lib/src/modules/settings/scenes/fvm_settings.scene.dart @@ -27,8 +27,8 @@ class FvmSettingsScene extends StatelessWidget { const SizedBox(height: 20), SwitchListTile( title: const Text('Git Cache'), - subtitle: const Text("This will cache the main Flutter repository" - " for faster and smaller installs"), + subtitle: const Text('This will cache the main Flutter repository' + ' for faster and smaller installs'), value: settings.fvm.gitCache ?? false, onChanged: (value) { settings.fvm.gitCache = value; @@ -38,8 +38,8 @@ class FvmSettingsScene extends StatelessWidget { const Divider(), SwitchListTile( title: const Text('Skip setup Flutter on install'), - subtitle: const Text("This will only clone Flutter and not install" - "dependencies after a new version is installed."), + subtitle: const Text('This will only clone Flutter and not install' + 'dependencies after a new version is installed.'), value: settings.fvm.skipSetup ?? false, onChanged: (value) { settings.fvm.skipSetup = value; diff --git a/lib/src/modules/settings/scenes/general_settings.scene.dart b/lib/src/modules/settings/scenes/general_settings.scene.dart index 512c76e3..f40de9af 100644 --- a/lib/src/modules/settings/scenes/general_settings.scene.dart +++ b/lib/src/modules/settings/scenes/general_settings.scene.dart @@ -24,12 +24,12 @@ class SettingsSectionGeneral extends StatelessWidget { Widget build(BuildContext context) { void handleReset() async { // flutter defined function - showDialog( + await showDialog( context: context, builder: (context) { // return object of type Dialog return AlertDialog( - title: const Text("Are you sure you want to reset settings?"), + title: const Text('Are you sure you want to reset settings?'), content: const Text( 'This will only reset Sidekick specific preferences', ), @@ -37,19 +37,19 @@ class SettingsSectionGeneral extends StatelessWidget { actions: [ // usually buttons at the bottom of the dialog TextButton( - child: const Text("Cancel"), onPressed: () { Navigator.of(context).pop(); }, + child: const Text('Cancel'), ), TextButton( - child: const Text("Confirm"), onPressed: () async { Navigator.of(context).pop(); settings.sidekick = SidekickSettings(); onSave(); notify('App settings have been reset'); }, + child: const Text('Confirm'), ), ], ); @@ -64,7 +64,7 @@ class SettingsSectionGeneral extends StatelessWidget { Text('General', style: Theme.of(context).textTheme.headline6), const SizedBox(height: 20), ListTile( - title: const Text("Theme"), + title: const Text('Theme'), subtitle: const Text( 'Select a theme or switch according to system settings..', ), @@ -74,16 +74,16 @@ class SettingsSectionGeneral extends StatelessWidget { value: settings.sidekick.themeMode.toString(), items: const [ DropdownMenuItem( - child: Text("System"), value: SettingsThemeMode.system, + child: Text('System'), ), DropdownMenuItem( - child: Text("Light"), value: SettingsThemeMode.light, + child: Text('Light'), ), DropdownMenuItem( - child: Text("Dark"), value: SettingsThemeMode.dark, + child: Text('Dark'), ), ], onChanged: (themeMode) async { diff --git a/lib/src/modules/settings/settings.dto.dart b/lib/src/modules/settings/settings.dto.dart index 0fbe729d..5a3f6cd5 100644 --- a/lib/src/modules/settings/settings.dto.dart +++ b/lib/src/modules/settings/settings.dto.dart @@ -16,16 +16,10 @@ class AllSettings { this.fvm, this.flutter, }) { - if (fvm == null) { - fvm = FvmSettings(); - } - if (sidekick == null) { - sidekick = SidekickSettings(); - } - - if (flutter == null) { - flutter = FlutterSettings(); - } + fvm ??= FvmSettings(); + sidekick ??= SidekickSettings(); + + flutter ??= FlutterSettings(); } AllSettings copy() => AllSettings( @@ -131,11 +125,11 @@ class FlutterSettings { /// Flutter settings to map Map toMap() { return { - "analytics": analytics, - "macos": macos, - "linux": linux, - "windows": windows, - "web": web, + 'analytics': analytics, + 'macos': macos, + 'linux': linux, + 'windows': windows, + 'web': web, }; } } diff --git a/lib/src/modules/settings/settings.provider.dart b/lib/src/modules/settings/settings.provider.dart index de3d3f6a..140a8767 100644 --- a/lib/src/modules/settings/settings.provider.dart +++ b/lib/src/modules/settings/settings.provider.dart @@ -65,9 +65,7 @@ class _SettingsStateNotifier extends StateNotifier { ); /// First run if it's null set - if (_prevState == null) { - _prevState = state.copy(); - } + _prevState ??= state.copy(); } /// Save settings diff --git a/lib/src/modules/updater/components/update_button.dart b/lib/src/modules/updater/components/update_button.dart index 6a94510f..58c0d248 100644 --- a/lib/src/modules/updater/components/update_button.dart +++ b/lib/src/modules/updater/components/update_button.dart @@ -34,28 +34,28 @@ class SkUpdateButton extends HookWidget { children: const [ Icon(MdiIcons.alertDecagram), SizedBox(width: 10), - Heading("Update available."), + Heading('Update available.'), ], ), content: Container( child: Paragraph( - "Sidekick version ${updateInfo.latest} is now available.", + 'Sidekick version ${updateInfo.latest} is now available.', ), ), actions: [ // usually buttons at the bottom of the dialog TextButton( - child: const Text("Later"), onPressed: () { Navigator.of(context).pop(); }, + child: const Text('Later'), ), ElevatedButton( - child: const Text("Update Now"), onPressed: () async { - updater.openInstaller(); + await updater.openInstaller(); Navigator.of(context).pop(); }, + child: const Text('Update Now'), ), ], ); diff --git a/lib/src/modules/updater/components/update_info.dart b/lib/src/modules/updater/components/update_info.dart index c054169b..5fcb9b72 100644 --- a/lib/src/modules/updater/components/update_info.dart +++ b/lib/src/modules/updater/components/update_info.dart @@ -26,8 +26,8 @@ class SkUpdateInfo extends HookWidget { ), const SizedBox(width: 5), TextButton( - child: const Text('Click here to download.'), onPressed: () {}, + child: const Text('Click here to download.'), ), ], ); @@ -39,13 +39,13 @@ class SkUpdateInfo extends HookWidget { const SizedBox(width: 5), const Text(packageVersion), const SizedBox(width: 20), - Text("${updateInfo.latest}"), + Text('${updateInfo.latest}'), const SizedBox(width: 20), OutlinedButton.icon( icon: Icon( updateInfo.needUpdate ? Icons.file_download : Icons.refresh, ), - label: Text("Refresh"), + label: Text('Refresh'), onPressed: updater.checkLatest, ), ], diff --git a/lib/src/modules/updater/updater.service.dart b/lib/src/modules/updater/updater.service.dart index b124bbeb..29bd88a0 100644 --- a/lib/src/modules/updater/updater.service.dart +++ b/lib/src/modules/updater/updater.service.dart @@ -27,7 +27,7 @@ class UpdaterService { /// Check if it has downloaded final file = await getDownloadFileLocation(latestVersion.toString()); - final downloadUrl = await getDownloadReleaseUrl(latestVersion.toString()); + final downloadUrl = getDownloadReleaseUrl(latestVersion.toString()); return SidekickUpdateInfo( needUpdate: needUpdate, @@ -58,8 +58,8 @@ class UpdaterService { return updateInfo.copyWith(isInstalled: true); } else { throw UpdaterException( - "There was an issue downloading the file, plese try again later.\n" - "Code ${res.statusCode}", + 'There was an issue downloading the file, plese try again later.\n' + 'Code ${res.statusCode}', ); } } @@ -69,7 +69,7 @@ class UpdaterService { static Future openInstaller(SidekickUpdateInfo updateInfo) async { if (updateInfo.isInstalled) { final file = updateInfo.latestInstallerFile; - openLink("file://${file.absolute.path.replaceAll("\\", "/")}"); + await openLink("file://${file.absolute.path.replaceAll("\\", "/")}"); } else { throw UpdaterException( 'Installer does not exists, you have to download it first', diff --git a/lib/src/modules/updater/updater.utils.dart b/lib/src/modules/updater/updater.utils.dart index c244310e..cd22f273 100644 --- a/lib/src/modules/updater/updater.utils.dart +++ b/lib/src/modules/updater/updater.utils.dart @@ -7,11 +7,11 @@ import '../common/constants.dart'; final _platform = Platform.operatingSystem; -const _downloadBaseUrl = "$kGithubSidekickUrl/releases/download"; +const _downloadBaseUrl = '$kGithubSidekickUrl/releases/download'; /// Download URL String getDownloadReleaseUrl(String release) { - return "$_downloadBaseUrl/$release/sidekick-$_platform-$release.$_platformExt"; + return '$_downloadBaseUrl/$release/sidekick-$_platform-$release.$_platformExt'; } /// File location for the download @@ -19,7 +19,7 @@ Future getDownloadFileLocation(String release) async { final downloadDir = await getDownloadsDirectory(); final filePath = p.join( downloadDir.absolute.path, - "sidekick-$release.$_platformExt", + 'sidekick-$release.$_platformExt', ); return File(filePath); } diff --git a/lib/src/screens/error_db_screen.dart b/lib/src/screens/error_db_screen.dart index a76d5e51..8abeb074 100644 --- a/lib/src/screens/error_db_screen.dart +++ b/lib/src/screens/error_db_screen.dart @@ -27,7 +27,7 @@ class ErrorDBScreen extends StatelessWidget { mainAxisSize: MainAxisSize.max, children: [ Text( - "There was an isssue opening Sidekick", + 'There was an isssue opening Sidekick', style: Theme.of(context).textTheme.headline4, textAlign: TextAlign.center, ), @@ -42,7 +42,7 @@ class ErrorDBScreen extends StatelessWidget { height: 20, ), ElevatedButton.icon( - label: const Text("Close"), + label: const Text('Close'), icon: const Icon(Icons.close), onPressed: () { exit(0); @@ -58,6 +58,6 @@ class ErrorDBScreen extends StatelessWidget { } } -const text = "Sidekick is having trouble reading its settings." - " Please make sure that there are no other instances of Sidekick running" - " and try again. If the problem persists, please open a Github Issue."; +const text = 'Sidekick is having trouble reading its settings.' + ' Please make sure that there are no other instances of Sidekick running' + ' and try again. If the problem persists, please open a Github Issue.'; diff --git a/lib/src/theme.dart b/lib/src/theme.dart index 85c60db6..24525554 100644 --- a/lib/src/theme.dart +++ b/lib/src/theme.dart @@ -110,8 +110,8 @@ ThemeData get lightTheme { ); } -get _textButtonThemeData { - TextButtonThemeData( +TextButtonThemeData get _textButtonThemeData { + return TextButtonThemeData( style: TextButton.styleFrom( tapTargetSize: MaterialTapTargetSize.padded, padding: const EdgeInsets.symmetric(horizontal: 20),