From b884342c6d5a2b4d25de74a1084d92bfde8ac684 Mon Sep 17 00:00:00 2001 From: Sachin Dapkara <92971894+superiorsd10@users.noreply.github.com> Date: Sun, 10 Dec 2023 16:00:17 +0530 Subject: [PATCH] Deprecation: Replaced the deprecated methods of url_launcher (#196) * replacing the deprecated methods * formatted the about view file --- .../about/controller/about_controller.dart | 13 ++-- lib/app/modules/about/views/about_view.dart | 59 +++++++++++-------- 2 files changed, 40 insertions(+), 32 deletions(-) diff --git a/lib/app/modules/about/controller/about_controller.dart b/lib/app/modules/about/controller/about_controller.dart index af657564..6993755c 100644 --- a/lib/app/modules/about/controller/about_controller.dart +++ b/lib/app/modules/about/controller/about_controller.dart @@ -1,16 +1,17 @@ import 'package:get/get.dart'; import 'package:ultimate_alarm_clock/app/modules/about/views/about_view.dart'; -import 'package:url_launcher/url_launcher.dart'; +import 'package:url_launcher/url_launcher_string.dart'; class AboutController extends GetxController { final RxBool isAboutExpanded = true.obs; - static const String ccExtractorUrl = "https://ccextractor.org/"; - static const String githubUrl = "https://github.com/CCExtractor/ultimate_alarm_clock"; + static const String ccExtractorUrl = 'https://ccextractor.org/'; + static const String githubUrl = + 'https://github.com/CCExtractor/ultimate_alarm_clock'; Future launchUrl(Uri uri) async { - if (await canLaunch(uri.toString())) { - return await launch(uri.toString()); + if (await canLaunchUrlString(uri.toString())) { + return await launchUrlString(uri.toString()); } else { return false; } @@ -23,4 +24,4 @@ class AboutController extends GetxController { void navigateToAboutView() { Get.to(() => AboutView()); } -} \ No newline at end of file +} diff --git a/lib/app/modules/about/views/about_view.dart b/lib/app/modules/about/views/about_view.dart index 05b3e5c8..a68d7730 100644 --- a/lib/app/modules/about/views/about_view.dart +++ b/lib/app/modules/about/views/about_view.dart @@ -10,17 +10,19 @@ class AboutView extends GetView { final AboutController aboutController = Get.find(); ThemeController themeController = Get.find(); - @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( - title: Text('About',style: Theme.of(context).textTheme.titleLarge!.copyWith( - color: themeController.isLightMode.value - ? kLightPrimaryTextColor - : kprimaryTextColor, - fontWeight: FontWeight.w500, - ),), + title: Text( + 'About', + style: Theme.of(context).textTheme.titleLarge!.copyWith( + color: themeController.isLightMode.value + ? kLightPrimaryTextColor + : kprimaryTextColor, + fontWeight: FontWeight.w500, + ), + ), elevation: 0, centerTitle: true, leading: IconButton( @@ -43,31 +45,33 @@ class AboutView extends GetView { ClipRRect( borderRadius: BorderRadius.circular(20), child: SizedBox.fromSize( - size: Size.fromRadius(48), + size: const Size.fromRadius(48), child: Image.asset('assets/images/ic_launcher-playstore.png'), ), ), - SizedBox(height: 10), - Text( + const SizedBox(height: 10), + const Text( 'Ultimate Alarm Clock', style: TextStyle( fontSize: 18, fontWeight: FontWeight.bold, ), ), - SizedBox(height: 10), - Text( + const SizedBox(height: 10), + const Text( 'Version: 1.0.0', style: TextStyle( fontSize: 16, fontWeight: FontWeight.bold, ), ), - SizedBox(height: 10), + const SizedBox(height: 10), Container( - padding: EdgeInsets.symmetric(horizontal: 20), - child: Text( - 'This project aims to build a non-conventional alarm clock with smart features such as auto-dismissal based on phone activity, weather, and more!', + padding: const EdgeInsets.symmetric(horizontal: 20), + child: const Text( + 'This project aims to build a non-conventional alarm clock' + ' with smart features such as auto-dismissal based on' + ' phone activity, weather, and more!', textAlign: TextAlign.center, style: TextStyle( fontSize: 14, @@ -75,7 +79,7 @@ class AboutView extends GetView { ), ), ), - SizedBox(height: 20), + const SizedBox(height: 20), Row( mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [ @@ -93,16 +97,17 @@ class AboutView extends GetView { if (!await aboutController .launchUrl(Uri.parse(AboutController.githubUrl))) { throw Exception( - 'Could not launch ${AboutController.githubUrl}'); + 'Could not launch ${AboutController.githubUrl}', + ); } }, icon: SvgPicture.asset( - "assets/images/github.svg", + 'assets/images/github.svg', width: 30, height: 30, ), - label: Text( - "GitHub", + label: const Text( + 'GitHub', style: TextStyle( color: Colors.black, fontWeight: FontWeight.w500, @@ -123,18 +128,20 @@ class AboutView extends GetView { ), onPressed: () async { if (!await aboutController.launchUrl( - Uri.parse(AboutController.ccExtractorUrl))) { + Uri.parse(AboutController.ccExtractorUrl), + )) { throw Exception( - 'Could not launch ${AboutController.ccExtractorUrl}'); + 'Could not launch ${AboutController.ccExtractorUrl}', + ); } }, icon: SvgPicture.asset( - "assets/images/link.svg", + 'assets/images/link.svg', width: 30, height: 30, ), - label: Text( - "CCExtractor", + label: const Text( + 'CCExtractor', style: TextStyle( color: Colors.black, fontWeight: FontWeight.w500,