From f5f2ff1b2c1ffcb2a3029cec85b82b2dead356d6 Mon Sep 17 00:00:00 2001 From: laurenspriem Date: Tue, 2 Sep 2025 11:49:12 +0530 Subject: [PATCH] Fix Flutter deprecation warnings - Replace withOpacity() with withValues(alpha:) - Replace onPopInvoked with onPopInvokedWithResult - Update MaterialState references to WidgetState Co-Authored-By: Claude --- .../image_editor/circular_icon_button.dart | 2 +- .../image_editor/image_editor_page.dart | 6 ++-- .../image_editor/image_editor_text_bar.dart | 8 +++--- .../image_editor/image_editor_tune_bar.dart | 4 +-- .../actions/smart_albums_status_widget.dart | 2 +- .../gallery/scrollbar/custom_scroll_bar.dart | 2 +- .../scroll_bar_with_use_notifier.dart | 28 +++++++++---------- 7 files changed, 26 insertions(+), 26 deletions(-) diff --git a/mobile/apps/photos/lib/ui/tools/editor/image_editor/circular_icon_button.dart b/mobile/apps/photos/lib/ui/tools/editor/image_editor/circular_icon_button.dart index 1ecc52a7b7..07dbef9f2d 100644 --- a/mobile/apps/photos/lib/ui/tools/editor/image_editor/circular_icon_button.dart +++ b/mobile/apps/photos/lib/ui/tools/editor/image_editor/circular_icon_button.dart @@ -39,7 +39,7 @@ class CircularIconButton extends StatelessWidget { ? Theme.of(context) .colorScheme .imageEditorPrimaryColor - .withOpacity(0.24) + .withValues(alpha: 0.24) : Theme.of(context).colorScheme.editorBackgroundColor, shape: BoxShape.circle, border: Border.all( diff --git a/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_page.dart b/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_page.dart index c059df86b0..3ce0df1849 100644 --- a/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_page.dart +++ b/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_page.dart @@ -179,7 +179,7 @@ class _ImageEditorPageState extends State { final textTheme = getEnteTextTheme(context); return PopScope( canPop: false, - onPopInvoked: (didPop) { + onPopInvokedWithResult: (didPop, result) { if (didPop) return; editorKey.currentState?.disablePopScope = true; _showExitConfirmationDialog(context); @@ -366,7 +366,7 @@ class _ImageEditorPageState extends State { margin: const EdgeInsets.only(bottom: 24), decoration: BoxDecoration( color: isHovered - ? colorScheme.warning400.withOpacity(0.8) + ? colorScheme.warning400.withValues(alpha: 0.8) : Colors.white, shape: BoxShape.circle, ), @@ -378,7 +378,7 @@ class _ImageEditorPageState extends State { isHovered ? Colors.white : colorScheme.warning400 - .withOpacity(0.8), + .withValues(alpha: 0.8), BlendMode.srcIn, ), ), diff --git a/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_text_bar.dart b/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_text_bar.dart index 51951833f7..564368a22a 100644 --- a/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_text_bar.dart +++ b/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_text_bar.dart @@ -233,10 +233,10 @@ class _BackgroundPickerWidget extends StatelessWidget { 'backgroundColor': Theme.of(context).colorScheme.editorBackgroundColor, 'border': null, 'textColor': Colors.black, - 'selectedInnerBackgroundColor': Colors.black.withOpacity(0.11), + 'selectedInnerBackgroundColor': Colors.black.withValues(alpha: 0.11), 'innerBackgroundColor': isLightMode - ? Colors.black.withOpacity(0.11) - : Colors.white.withOpacity(0.11), + ? Colors.black.withValues(alpha: 0.11) + : Colors.white.withValues(alpha: 0.11), }, LayerBackgroundMode.onlyColor: { 'text': 'Aa', @@ -247,7 +247,7 @@ class _BackgroundPickerWidget extends StatelessWidget { isLightMode ? null : Border.all(color: Colors.white, width: 2), 'textColor': Colors.black, 'selectedInnerBackgroundColor': Colors.white, - 'innerBackgroundColor': Colors.white.withOpacity(0.6), + 'innerBackgroundColor': Colors.white.withValues(alpha: 0.6), }, }; diff --git a/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_tune_bar.dart b/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_tune_bar.dart index 7dcf73d4ed..45e0411e1a 100644 --- a/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_tune_bar.dart +++ b/mobile/apps/photos/lib/ui/tools/editor/image_editor/image_editor_tune_bar.dart @@ -320,11 +320,11 @@ class _CircularProgressWithValueState extends State decoration: BoxDecoration( shape: BoxShape.circle, color: showValue || widget.isSelected - ? progressColor.withOpacity(0.2) + ? progressColor.withValues(alpha: 0.2) : Theme.of(context).colorScheme.editorBackgroundColor, border: Border.all( color: widget.isSelected - ? progressColor.withOpacity(0.4) + ? progressColor.withValues(alpha: 0.4) : Theme.of(context).colorScheme.editorBackgroundColor, width: 2, ), diff --git a/mobile/apps/photos/lib/ui/viewer/actions/smart_albums_status_widget.dart b/mobile/apps/photos/lib/ui/viewer/actions/smart_albums_status_widget.dart index 5b042d9e45..366a108b8e 100644 --- a/mobile/apps/photos/lib/ui/viewer/actions/smart_albums_status_widget.dart +++ b/mobile/apps/photos/lib/ui/viewer/actions/smart_albums_status_widget.dart @@ -80,7 +80,7 @@ class _SmartAlbumsStatusWidgetState extends State .copyWith(left: 14), decoration: BoxDecoration( borderRadius: BorderRadius.circular(8), - color: Colors.black.withOpacity(0.65), + color: Colors.black.withValues(alpha: 0.65), ), child: Row( mainAxisSize: MainAxisSize.min, diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/scrollbar/custom_scroll_bar.dart b/mobile/apps/photos/lib/ui/viewer/gallery/scrollbar/custom_scroll_bar.dart index 3c25a9ed4b..24b127eb18 100644 --- a/mobile/apps/photos/lib/ui/viewer/gallery/scrollbar/custom_scroll_bar.dart +++ b/mobile/apps/photos/lib/ui/viewer/gallery/scrollbar/custom_scroll_bar.dart @@ -279,7 +279,7 @@ class ScrollBarDivider extends StatelessWidget { // is affected. boxShadow: [ BoxShadow( - color: Colors.black.withOpacity(0.1), + color: Colors.black.withValues(alpha: 0.1), blurRadius: 3, offset: const Offset(0, 2), ), diff --git a/mobile/apps/photos/lib/ui/viewer/gallery/scrollbar/scroll_bar_with_use_notifier.dart b/mobile/apps/photos/lib/ui/viewer/gallery/scrollbar/scroll_bar_with_use_notifier.dart index c0a2b27608..9e14afc698 100644 --- a/mobile/apps/photos/lib/ui/viewer/gallery/scrollbar/scroll_bar_with_use_notifier.dart +++ b/mobile/apps/photos/lib/ui/viewer/gallery/scrollbar/scroll_bar_with_use_notifier.dart @@ -53,11 +53,11 @@ const Duration _kScrollbarTimeToFade = Duration(milliseconds: 600); /// {@end-tool} /// /// A scrollbar track can be added using [trackVisibility]. This can also be -/// drawn when triggered by a hover event, or based on any [MaterialState] by +/// drawn when triggered by a hover event, or based on any [WidgetState] by /// using [ScrollbarThemeData.trackVisibility]. /// /// The [thickness] of the track and scrollbar thumb can be changed dynamically -/// in response to [MaterialState]s using [ScrollbarThemeData.thickness]. +/// in response to [WidgetState]s using [ScrollbarThemeData.thickness]. /// /// See also: /// @@ -262,17 +262,17 @@ class _MaterialScrollbarState extends RawScrollbarState<_MaterialScrollbar> { late Color idleColor; switch (brightness) { case Brightness.light: - dragColor = onSurface.withOpacity(0.6); - hoverColor = onSurface.withOpacity(0.5); + dragColor = onSurface.withValues(alpha: 0.6); + hoverColor = onSurface.withValues(alpha: 0.5); idleColor = _useAndroidScrollbar - ? Theme.of(context).highlightColor.withOpacity(1.0) - : onSurface.withOpacity(0.1); + ? Theme.of(context).highlightColor.withValues(alpha: 1.0) + : onSurface.withValues(alpha: 0.1); case Brightness.dark: - dragColor = onSurface.withOpacity(0.75); - hoverColor = onSurface.withOpacity(0.65); + dragColor = onSurface.withValues(alpha: 0.75); + hoverColor = onSurface.withValues(alpha: 0.65); idleColor = _useAndroidScrollbar - ? Theme.of(context).highlightColor.withOpacity(1.0) - : onSurface.withOpacity(0.3); + ? Theme.of(context).highlightColor.withValues(alpha: 1.0) + : onSurface.withValues(alpha: 0.3); } return WidgetStateProperty.resolveWith((Set states) { @@ -304,8 +304,8 @@ class _MaterialScrollbarState extends RawScrollbarState<_MaterialScrollbar> { if (showScrollbar && _trackVisibility.resolve(states)) { return _scrollbarTheme.trackColor?.resolve(states) ?? switch (brightness) { - Brightness.light => onSurface.withOpacity(0.03), - Brightness.dark => onSurface.withOpacity(0.05), + Brightness.light => onSurface.withValues(alpha: 0.03), + Brightness.dark => onSurface.withValues(alpha: 0.05), }; } return const Color(0x00000000); @@ -322,8 +322,8 @@ class _MaterialScrollbarState extends RawScrollbarState<_MaterialScrollbar> { if (showScrollbar && _trackVisibility.resolve(states)) { return _scrollbarTheme.trackBorderColor?.resolve(states) ?? switch (brightness) { - Brightness.light => onSurface.withOpacity(0.1), - Brightness.dark => onSurface.withOpacity(0.25), + Brightness.light => onSurface.withValues(alpha: 0.1), + Brightness.dark => onSurface.withValues(alpha: 0.25), }; } return const Color(0x00000000);