Skip to content

Commit 89715c9

Browse files
committed
fix: deprecations fixed as of flutter 3.27
1 parent aac2499 commit 89715c9

File tree

10 files changed

+35
-22
lines changed

10 files changed

+35
-22
lines changed

Diff for: analysis_options.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
analyzer:
2+
errors:
3+
unintended_html_in_doc_comment: ignore
14
include: package:flutter_lints/flutter.yaml
25

36
linter:

Diff for: lib/src/extensions/misc_ext.dart

+10-8
Original file line numberDiff line numberDiff line change
@@ -111,12 +111,14 @@ extension VxColorExtension on Color {
111111
MaterialColor materialColor() => Vx.getMaterialColor(this);
112112

113113
/// whether the color is transparent or not
114-
bool get isTransparent => alpha == 0;
114+
bool get isTransparent => a == 0;
115115

116116
/// Get the swatch of the color
117-
MaterialColor get swatch =>
118-
Colors.primaries.firstWhere((Color c) => c.value == value,
119-
orElse: () => MaterialColor(value, getMaterialColorValues));
117+
MaterialColor get swatch => Colors.primaries.firstWhere(
118+
(Color c) => c.r == r && c.g == g && c.b == b && c.a == a,
119+
orElse: () => MaterialColor(
120+
(a.toInt() << 24) | (r.toInt() << 16) | (g.toInt() << 8) | b.toInt(),
121+
getMaterialColorValues));
120122

121123
/// Get MaterialColor values from the current color
122124
Map<int, Color> get getMaterialColorValues => {
@@ -150,8 +152,8 @@ extension VxColorExtension on Color {
150152

151153
/// Prefixes a hash sign if [leadingHashSign] is set to `true` and returns the hexadecimal string value of the color.
152154
String toHex({bool leadingHashSign = true}) => '${leadingHashSign ? '#' : ''}'
153-
'${alpha.toRadixString(16).padLeft(2, '0')}'
154-
'${red.toRadixString(16).padLeft(2, '0')}'
155-
'${green.toRadixString(16).padLeft(2, '0')}'
156-
'${blue.toRadixString(16).padLeft(2, '0')}';
155+
'${a.round().toRadixString(16).padLeft(2, '0')}'
156+
'${r.round().toRadixString(16).padLeft(2, '0')}'
157+
'${g.round().toRadixString(16).padLeft(2, '0')}'
158+
'${b.round().toRadixString(16).padLeft(2, '0')}';
157159
}

Diff for: lib/src/flutter/animated/animated_container.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ class VxAnimatedBox extends VxWidgetBuilder<Widget>
201201
VxAnimatedBox shadowOutline({Color? outlineColor}) {
202202
_boxShadow = [
203203
BoxShadow(
204-
color: outlineColor?.withOpacity(0.5) ??
204+
color: outlineColor?.withValues(alpha: 0.5) ??
205205
const Color.fromRGBO(66, 153, 225, 0.5),
206206
blurRadius: 0.0,
207207
spreadRadius: 3.0,

Diff for: lib/src/flutter/container.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ class VxBox extends VxWidgetBuilder<Widget>
197197
VxBox shadowOutline({Color? outlineColor}) {
198198
_boxShadow = [
199199
BoxShadow(
200-
color: outlineColor?.withOpacity(0.5) ??
200+
color: outlineColor?.withValues(alpha: 0.5) ??
201201
const Color.fromRGBO(66, 153, 225, 0.5),
202202
blurRadius: 0.0,
203203
spreadRadius: 3.0,

Diff for: lib/src/flutter/drawer.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ mixin VxDrawer {
8383

8484
overlayEntry = OverlayEntry(
8585
builder: (BuildContext context) => PopScope(
86-
onPopInvoked: backClose,
86+
onPopInvokedWithResult: (_, __) => backClose,
8787
child: _VxDrawer(
8888
key: key,
8989
type: type,

Diff for: lib/src/flutter/glass.dart

+4-3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
*/
1313

1414
import 'dart:ui';
15+
1516
import 'package:flutter/material.dart';
1617

1718
class VxGlassmorphic extends StatelessWidget {
@@ -84,7 +85,7 @@ class VxGlassmorphic extends StatelessWidget {
8485
borderRadius: borderRadius ?? BorderRadius.circular(circularRadius!),
8586
border: border ??
8687
Border.all(
87-
color: Colors.white.withOpacity(0.3),
88+
color: Colors.white.withValues(alpha: 0.3),
8889
width: 0.3,
8990
style: BorderStyle.solid),
9091
),
@@ -100,7 +101,7 @@ class VxGlassmorphic extends StatelessWidget {
100101
decoration: BoxDecoration(
101102
borderRadius:
102103
borderRadius ?? BorderRadius.circular(circularRadius!),
103-
color: Colors.grey[100]?.withOpacity(opacity!),
104+
color: Colors.grey[100]?.withValues(alpha: opacity!),
104105
),
105106
child: child,
106107
),
@@ -129,7 +130,7 @@ class _PaintShadow extends CustomPainter {
129130
double? strokeWidth}) {
130131
return Paint()
131132
..style = PaintingStyle.stroke
132-
..color = color!.withOpacity(0.24)
133+
..color = color!.withValues(alpha: 0.24)
133134
..strokeWidth = strokeWidth!
134135
..maskFilter = MaskFilter.blur(
135136
BlurStyle.normal,

Diff for: lib/src/flutter/platforms.dart

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import 'package:flutter/material.dart';
44

55
/// Sample
66
///
7+
// ignore: unintended_html_in_doc_comment
78
/// class PlatformAppBar extends VxPlatform<AppBar, CupertinoNavigationBar, AppBar, AppBar> {
89
/// final Widget title;
910
/// final Widget leading;

Diff for: lib/src/flutter/popup_menu.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,7 @@ class VxPopupMenuState extends State<VxPopupMenu> {
200200
Widget build(BuildContext context) {
201201
return PopScope(
202202
canPop: true,
203-
onPopInvoked: (_) => _hideMenu(),
203+
onPopInvokedWithResult: (_, __) => _hideMenu(),
204204
child: GestureDetector(
205205
behavior: HitTestBehavior.translucent,
206206
child: widget.child,

Diff for: lib/src/flutter/velocityx_mixins/neu_mixin.dart

+3-3
Original file line numberDiff line numberDiff line change
@@ -106,9 +106,9 @@ mixin VxNeuMixin {
106106

107107
Color _getNeuColor(Color baseColor, double amount) {
108108
Map<String, int> colors = {
109-
'r': baseColor.red,
110-
'g': baseColor.green,
111-
'b': baseColor.blue
109+
'r': baseColor.r.toInt(),
110+
'g': baseColor.g.toInt(),
111+
'b': baseColor.b.toInt()
112112
};
113113

114114
colors = colors.map((key, value) {

Diff for: lib/src/velocity_xx.dart

+10-4
Original file line numberDiff line numberDiff line change
@@ -759,9 +759,9 @@ mixin Vx {
759759
}
760760

761761
static MaterialColor getMaterialColor(Color color) {
762-
final int red = color.red;
763-
final int green = color.green;
764-
final int blue = color.blue;
762+
final int red = color.r.toInt();
763+
final int green = color.g.toInt();
764+
final int blue = color.b.toInt();
765765

766766
final Map<int, Color> shades = {
767767
50: Color.fromRGBO(red, green, blue, .1),
@@ -776,7 +776,13 @@ mixin Vx {
776776
900: Color.fromRGBO(red, green, blue, 1),
777777
};
778778

779-
return MaterialColor(color.value, shades);
779+
return MaterialColor(
780+
(color.a.toInt() << 24) |
781+
(color.r.toInt() << 16) |
782+
(color.g.toInt() << 8) |
783+
color.b.toInt(),
784+
shades,
785+
);
780786
}
781787

782788
/// Get Color in [int]

0 commit comments

Comments
 (0)