From 4ebf46d2fd81e1d0aaf40d82e4d18147c564281f Mon Sep 17 00:00:00 2001 From: "Dr.Blank" Date: Thu, 10 Apr 2025 19:42:08 +0530 Subject: [PATCH] chore: remove deprecated apis (#74) * dart format + remove withopacity * remove unused imports --- lib/constants/hero_tag_conventions.dart | 1 - lib/features/explore/view/explore_page.dart | 6 ++++-- .../view/library_item_hero_section.dart | 10 ++++++---- .../item_viewer/view/library_item_metadata.dart | 9 ++++++--- lib/features/onboarding/view/user_login.dart | 1 - .../view/user_login_with_password.dart | 9 ++++++--- .../onboarding/view/user_login_with_token.dart | 5 ++++- .../player/view/player_when_expanded.dart | 8 +++++--- .../player/view/player_when_minimized.dart | 2 +- .../player/view/widgets/speed_selector.dart | 1 - .../sleep_timer/view/sleep_timer_button.dart | 1 - lib/features/you/view/server_manager.dart | 2 -- lib/pages/home_page.dart | 2 +- lib/pages/library_page.dart | 2 +- lib/router/models/library_item_extras.dart | 1 - lib/settings/constants.dart | 1 - .../widgets/navigation_with_switch_tile.dart | 2 +- lib/shared/utils.dart | 1 - lib/shared/widgets/add_new_server.dart | 2 +- lib/shared/widgets/drawer.dart | 1 - lib/shared/widgets/expandable_description.dart | 2 +- lib/shared/widgets/shelves/book_shelf.dart | 16 +++++++++++----- 22 files changed, 48 insertions(+), 37 deletions(-) diff --git a/lib/constants/hero_tag_conventions.dart b/lib/constants/hero_tag_conventions.dart index 6934c00..4ec40a9 100644 --- a/lib/constants/hero_tag_conventions.dart +++ b/lib/constants/hero_tag_conventions.dart @@ -10,5 +10,4 @@ class HeroTagPrefixes { static const String bookTitle = 'book_title_'; static const String narratorName = 'narrator_name_'; static const String libraryItemPlayButton = 'library_item_play_button_'; - } diff --git a/lib/features/explore/view/explore_page.dart b/lib/features/explore/view/explore_page.dart index 2a46983..23bb0f6 100644 --- a/lib/features/explore/view/explore_page.dart +++ b/lib/features/explore/view/explore_page.dart @@ -98,8 +98,10 @@ class MySearchBar extends HookConsumerWidget { // opacity: 0.5 for the hint text hintStyle: WidgetStatePropertyAll( Theme.of(context).textTheme.bodyMedium!.copyWith( - color: - Theme.of(context).colorScheme.onSurface.withOpacity(0.5), + color: Theme.of(context) + .colorScheme + .onSurface + .withValues(alpha: 0.5), ), ), textInputAction: TextInputAction.search, diff --git a/lib/features/item_viewer/view/library_item_hero_section.dart b/lib/features/item_viewer/view/library_item_hero_section.dart index 45edc02..da4adea 100644 --- a/lib/features/item_viewer/view/library_item_hero_section.dart +++ b/lib/features/item_viewer/view/library_item_hero_section.dart @@ -199,8 +199,10 @@ class _LibraryItemProgressIndicator extends HookConsumerWidget { '${remainingTime.smartBinaryFormat} left', style: Theme.of(context).textTheme.bodySmall?.copyWith( - color: - Theme.of(context).colorScheme.onSurface.withOpacity(0.75), + color: Theme.of(context) + .colorScheme + .onSurface + .withValues(alpha: 0.75), ), ), ], @@ -227,7 +229,7 @@ class _HeroSectionSubLabelWithIcon extends HookConsumerWidget { ref.watch(appSettingsProvider).themeSettings.useMaterialThemeOnItemPage; final color = useMaterialThemeOnItemPage ? themeData.colorScheme.primary - : themeData.colorScheme.onSurface.withOpacity(0.75); + : themeData.colorScheme.onSurface.withValues(alpha: 0.75); return Padding( padding: const EdgeInsets.only(bottom: 8.0), child: Row( @@ -443,7 +445,7 @@ class _BookTitle extends StatelessWidget { ? const SizedBox.shrink() : Text( style: themeData.textTheme.titleSmall?.copyWith( - color: themeData.colorScheme.onSurface.withOpacity(0.8), + color: themeData.colorScheme.onSurface.withValues(alpha: 0.8), ), itemBookMetadata?.subtitle ?? '', ), diff --git a/lib/features/item_viewer/view/library_item_metadata.dart b/lib/features/item_viewer/view/library_item_metadata.dart index b08948e..664daac 100644 --- a/lib/features/item_viewer/view/library_item_metadata.dart +++ b/lib/features/item_viewer/view/library_item_metadata.dart @@ -96,7 +96,10 @@ class LibraryItemMetadata extends HookConsumerWidget { return VerticalDivider( indent: 6, endIndent: 6, - color: Theme.of(context).colorScheme.onSurface.withOpacity(0.6), + color: Theme.of(context) + .colorScheme + .onSurface + .withValues(alpha: 0.6), ); }, ), @@ -125,7 +128,7 @@ class _MetadataItem extends StatelessWidget { children: [ Text( style: themeData.textTheme.titleMedium?.copyWith( - color: themeData.colorScheme.onSurface.withOpacity(0.90), + color: themeData.colorScheme.onSurface.withValues(alpha: 0.90), ), value, maxLines: 1, @@ -133,7 +136,7 @@ class _MetadataItem extends StatelessWidget { ), Text( style: themeData.textTheme.bodySmall?.copyWith( - color: themeData.colorScheme.onSurface.withOpacity(0.7), + color: themeData.colorScheme.onSurface.withValues(alpha: 0.7), ), title, maxLines: 1, diff --git a/lib/features/onboarding/view/user_login.dart b/lib/features/onboarding/view/user_login.dart index c534d0d..bf65b12 100644 --- a/lib/features/onboarding/view/user_login.dart +++ b/lib/features/onboarding/view/user_login.dart @@ -175,7 +175,6 @@ class UserLoginMultipleAuth extends HookConsumerWidget { ], ), ), - Padding( padding: const EdgeInsets.all(8.0), child: switch (methodChoice.value) { diff --git a/lib/features/onboarding/view/user_login_with_password.dart b/lib/features/onboarding/view/user_login_with_password.dart index 533b37b..b730cc5 100644 --- a/lib/features/onboarding/view/user_login_with_password.dart +++ b/lib/features/onboarding/view/user_login_with_password.dart @@ -107,7 +107,7 @@ class UserLoginWithPassword extends HookConsumerWidget { color: Theme.of(context) .colorScheme .onSurface - .withOpacity(0.8), + .withValues(alpha: 0.8), ), border: const OutlineInputBorder(), ), @@ -127,12 +127,15 @@ class UserLoginWithPassword extends HookConsumerWidget { color: Theme.of(context) .colorScheme .onSurface - .withOpacity(0.8), + .withValues(alpha: 0.8), ), border: const OutlineInputBorder(), suffixIcon: ColorFiltered( colorFilter: ColorFilter.mode( - Theme.of(context).colorScheme.primary.withOpacity(0.8), + Theme.of(context) + .colorScheme + .primary + .withValues(alpha: 0.8), BlendMode.srcIn, ), child: InkWell( diff --git a/lib/features/onboarding/view/user_login_with_token.dart b/lib/features/onboarding/view/user_login_with_token.dart index 35cdf55..a67b96b 100644 --- a/lib/features/onboarding/view/user_login_with_token.dart +++ b/lib/features/onboarding/view/user_login_with_token.dart @@ -84,7 +84,10 @@ class UserLoginWithToken extends HookConsumerWidget { decoration: InputDecoration( labelText: 'API Token', labelStyle: TextStyle( - color: Theme.of(context).colorScheme.onSurface.withOpacity(0.8), + color: Theme.of(context) + .colorScheme + .onSurface + .withValues(alpha: 0.8), ), border: const OutlineInputBorder(), ), diff --git a/lib/features/player/view/player_when_expanded.dart b/lib/features/player/view/player_when_expanded.dart index 5fe0ea7..0deda52 100644 --- a/lib/features/player/view/player_when_expanded.dart +++ b/lib/features/player/view/player_when_expanded.dart @@ -104,8 +104,10 @@ class PlayerWhenExpanded extends HookConsumerWidget { decoration: BoxDecoration( boxShadow: [ BoxShadow( - color: - Theme.of(context).colorScheme.primary.withOpacity(0.1), + color: Theme.of(context) + .colorScheme + .primary + .withValues(alpha: 0.1), blurRadius: 32 * earlyPercentage, spreadRadius: 8 * earlyPercentage, // offset: Offset(0, 16 * earlyPercentage), @@ -171,7 +173,7 @@ class PlayerWhenExpanded extends HookConsumerWidget { color: Theme.of(context) .colorScheme .onSurface - .withOpacity(0.7), + .withValues(alpha: 0.7), ), maxLines: 1, overflow: TextOverflow.ellipsis, diff --git a/lib/features/player/view/player_when_minimized.dart b/lib/features/player/view/player_when_minimized.dart index 435a6de..1a5774b 100644 --- a/lib/features/player/view/player_when_minimized.dart +++ b/lib/features/player/view/player_when_minimized.dart @@ -93,7 +93,7 @@ class PlayerWhenMinimized extends HookConsumerWidget { color: Theme.of(context) .colorScheme .onSurface - .withOpacity(0.7), + .withValues(alpha: 0.7), ), ), ], diff --git a/lib/features/player/view/widgets/speed_selector.dart b/lib/features/player/view/widgets/speed_selector.dart index 65a3bfa..ab564b1 100644 --- a/lib/features/player/view/widgets/speed_selector.dart +++ b/lib/features/player/view/widgets/speed_selector.dart @@ -6,7 +6,6 @@ import 'package:hooks_riverpod/hooks_riverpod.dart'; import 'package:list_wheel_scroll_view_nls/list_wheel_scroll_view_nls.dart'; import 'package:vaani/features/player/providers/audiobook_player.dart'; import 'package:vaani/settings/app_settings_provider.dart'; -import 'package:vaani/shared/hooks.dart'; const double itemExtent = 25; diff --git a/lib/features/sleep_timer/view/sleep_timer_button.dart b/lib/features/sleep_timer/view/sleep_timer_button.dart index 075b0e4..9712813 100644 --- a/lib/features/sleep_timer/view/sleep_timer_button.dart +++ b/lib/features/sleep_timer/view/sleep_timer_button.dart @@ -11,7 +11,6 @@ import 'package:vaani/features/sleep_timer/providers/sleep_timer_provider.dart' import 'package:vaani/main.dart'; import 'package:vaani/settings/app_settings_provider.dart'; import 'package:vaani/shared/extensions/duration_format.dart'; -import 'package:vaani/shared/hooks.dart'; class SleepTimerButton extends HookConsumerWidget { const SleepTimerButton({ diff --git a/lib/features/you/view/server_manager.dart b/lib/features/you/view/server_manager.dart index 43c8d24..f44eb77 100644 --- a/lib/features/you/view/server_manager.dart +++ b/lib/features/you/view/server_manager.dart @@ -261,9 +261,7 @@ class ServerManagerPage extends HookConsumerWidget { }, ), ), - MiniPlayerBottomPadding(), - ], ), ), diff --git a/lib/pages/home_page.dart b/lib/pages/home_page.dart index 4ff81c4..682a8a4 100644 --- a/lib/pages/home_page.dart +++ b/lib/pages/home_page.dart @@ -76,7 +76,7 @@ class HomePage extends HookConsumerWidget { child: ListView.separated( itemBuilder: (context, index) => shelvesToDisplay[index], separatorBuilder: (context, index) => Divider( - color: Theme.of(context).dividerColor.withOpacity(0.1), + color: Theme.of(context).dividerColor.withValues(alpha: 0.1), indent: 16, endIndent: 16, ), diff --git a/lib/pages/library_page.dart b/lib/pages/library_page.dart index 18eedee..a6950a6 100644 --- a/lib/pages/library_page.dart +++ b/lib/pages/library_page.dart @@ -61,7 +61,7 @@ class LibraryPage extends HookConsumerWidget { child: ListView.separated( itemBuilder: (context, index) => shelvesToDisplay[index], separatorBuilder: (context, index) => Divider( - color: Theme.of(context).dividerColor.withOpacity(0.1), + color: Theme.of(context).dividerColor.withValues(alpha: 0.1), indent: 16, endIndent: 16, ), diff --git a/lib/router/models/library_item_extras.dart b/lib/router/models/library_item_extras.dart index 0d50040..55b734e 100644 --- a/lib/router/models/library_item_extras.dart +++ b/lib/router/models/library_item_extras.dart @@ -16,5 +16,4 @@ class LibraryItemExtras with _$LibraryItemExtras { BookMinified? book, @Default('') String heroTagSuffix, }) = _LibraryItemExtras; - } diff --git a/lib/settings/constants.dart b/lib/settings/constants.dart index 9ab7b55..3b836d3 100644 --- a/lib/settings/constants.dart +++ b/lib/settings/constants.dart @@ -1,6 +1,5 @@ import 'package:flutter/foundation.dart' show immutable; - @immutable class AppMetadata { const AppMetadata._(); diff --git a/lib/settings/view/widgets/navigation_with_switch_tile.dart b/lib/settings/view/widgets/navigation_with_switch_tile.dart index dbc8ecf..8851fa1 100644 --- a/lib/settings/view/widgets/navigation_with_switch_tile.dart +++ b/lib/settings/view/widgets/navigation_with_switch_tile.dart @@ -40,7 +40,7 @@ class NavigationWithSwitchTile extends AbstractSettingsTile { child: Row( children: [ VerticalDivider( - color: Theme.of(context).dividerColor.withOpacity(0.5), + color: Theme.of(context).dividerColor.withValues(alpha: 0.5), indent: 8.0, endIndent: 8.0, ), diff --git a/lib/shared/utils.dart b/lib/shared/utils.dart index 6fce1a0..3d600b4 100644 --- a/lib/shared/utils.dart +++ b/lib/shared/utils.dart @@ -1,4 +1,3 @@ - import 'package:flutter/material.dart'; import 'package:url_launcher/url_launcher.dart'; diff --git a/lib/shared/widgets/add_new_server.dart b/lib/shared/widgets/add_new_server.dart index a0c10e6..8c31fc1 100644 --- a/lib/shared/widgets/add_new_server.dart +++ b/lib/shared/widgets/add_new_server.dart @@ -68,7 +68,7 @@ class AddNewServer extends HookConsumerWidget { decoration: InputDecoration( labelText: 'Server URI', labelStyle: TextStyle( - color: Theme.of(context).colorScheme.onSurface.withOpacity(0.8), + color: Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.8), ), border: const OutlineInputBorder(), prefixText: diff --git a/lib/shared/widgets/drawer.dart b/lib/shared/widgets/drawer.dart index be224e9..12aa1c2 100644 --- a/lib/shared/widgets/drawer.dart +++ b/lib/shared/widgets/drawer.dart @@ -3,7 +3,6 @@ import 'package:go_router/go_router.dart'; import 'package:vaani/features/you/view/server_manager.dart'; import 'package:vaani/router/router.dart'; - class MyDrawer extends StatelessWidget { const MyDrawer({ super.key, diff --git a/lib/shared/widgets/expandable_description.dart b/lib/shared/widgets/expandable_description.dart index 06605e4..203c7b0 100644 --- a/lib/shared/widgets/expandable_description.dart +++ b/lib/shared/widgets/expandable_description.dart @@ -39,7 +39,7 @@ class ExpandableDescription extends HookWidget { // header with carrot icon is tapable InkWell( borderRadius: BorderRadius.circular(8), - + onTap: () { isDescExpanded.value = !isDescExpanded.value; if (isDescExpanded.value) { diff --git a/lib/shared/widgets/shelves/book_shelf.dart b/lib/shared/widgets/shelves/book_shelf.dart index 1ef7089..4490b99 100644 --- a/lib/shared/widgets/shelves/book_shelf.dart +++ b/lib/shared/widgets/shelves/book_shelf.dart @@ -255,8 +255,10 @@ class _BookOnShelfPlayButton extends HookConsumerWidget { child: CircularProgressIndicator( value: userProgress.progress, strokeWidth: strokeWidth, - backgroundColor: - Theme.of(context).colorScheme.onPrimary.withOpacity(0.8), + backgroundColor: Theme.of(context) + .colorScheme + .onPrimary + .withValues(alpha: 0.8), valueColor: AlwaysStoppedAnimation( Theme.of(context).colorScheme.primary, ), @@ -274,7 +276,10 @@ class _BookOnShelfPlayButton extends HookConsumerWidget { const Size(size, size), ), backgroundColor: WidgetStateProperty.all( - Theme.of(context).colorScheme.onPrimary.withOpacity(0.9), + Theme.of(context) + .colorScheme + .onPrimary + .withValues(alpha: 0.9), ), ), onPressed: () async { @@ -316,9 +321,10 @@ class BookCoverSkeleton extends StatelessWidget { child: SizedBox( width: 150, child: Shimmer.fromColors( - baseColor: Theme.of(context).colorScheme.surface.withOpacity(0.3), + baseColor: + Theme.of(context).colorScheme.surface.withValues(alpha: 0.3), highlightColor: - Theme.of(context).colorScheme.onSurface.withOpacity(0.1), + Theme.of(context).colorScheme.onSurface.withValues(alpha: 0.1), child: Container( color: Theme.of(context).colorScheme.surface, ),