Fix Flutter deprecation warnings

- Replace withOpacity() with withValues(alpha:)
- Replace onPopInvoked with onPopInvokedWithResult
- Update MaterialState references to WidgetState

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
laurenspriem
2025-09-02 11:49:12 +05:30
parent 0c2b38c059
commit f5f2ff1b2c
7 changed files with 26 additions and 26 deletions

View File

@@ -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(

View File

@@ -179,7 +179,7 @@ class _ImageEditorPageState extends State<ImageEditorPage> {
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<ImageEditorPage> {
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<ImageEditorPage> {
isHovered
? Colors.white
: colorScheme.warning400
.withOpacity(0.8),
.withValues(alpha: 0.8),
BlendMode.srcIn,
),
),

View File

@@ -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),
},
};

View File

@@ -320,11 +320,11 @@ class _CircularProgressWithValueState extends State<CircularProgressWithValue>
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,
),

View File

@@ -80,7 +80,7 @@ class _SmartAlbumsStatusWidgetState extends State<SmartAlbumsStatusWidget>
.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,

View File

@@ -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),
),

View File

@@ -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<WidgetState> 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);