Skip to content

Commit

Permalink
Document usage of deprecations
Browse files Browse the repository at this point in the history
  • Loading branch information
passsy committed Dec 23, 2024
1 parent 5a197c4 commit e77353d
Show file tree
Hide file tree
Showing 25 changed files with 130 additions and 4 deletions.
33 changes: 33 additions & 0 deletions RELEASE.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,3 +14,36 @@
- Update wiredash-demo project for website
- Update latest SDK version in `console`
- Announce release on Twitter 🎉


## Handling deprecations of the Flutter SDK and dependencies

The Wiredash SDK strives to be compatible with all `stable` [Flutter releases](https://docs.flutter.dev/release/archive) within the last year as well as the current `master` channel.
To achieve this, we go the extra mile and work around breaking API changes or contribute fixes directly to the Flutter SDK to ensure compatibility.

The goal is to always have a single commit, being compatible with all versions.
This way we can make sure to deliver the latest features and bug fixes to all of our users.

These are the current deprecated APIs the Wiredash SDK is currently using as long as the deprecated APIs are not removed (usually after 12 months).

### Flutter v3.28 / Dart 3.6.0

- New `WidgetInspector` constructor https://github.com/flutter/flutter/pull/158219

### Flutter 3.27 / Dart 3.6.0

Multiple `Color` API changes
- https://docs.flutter.dev/release/breaking-changes/wide-gamut-framework
- https://github.com/flutter/engine/pull/54737

- `Color.alpha` -> `Color.a`
- `Color.red` -> `Color.r`
- `Color.green` -> `Color.g`
- `Color.blue` -> `Color.b`
- `Color.withOpacity()` -> `Color.withValues()`
- `Color.value` -> ?

### Flutter 3.10 / Dart 3.0.0

- `Iterable<T?>.whereNotNull()` -> `Iterable<T>.nonNulls` (Caused by pinned [`collection: 1.19.0`](https://pub.dev/packages/collection/changelog#1190) package)
- `MediaQuery.fromWindow` -> `MediaQuery.fromView` (deprecated in Flutter v3.7.0-32.0.pre) https://github.com/flutter/flutter/pull/119647
22 changes: 22 additions & 0 deletions examples/theme_editor/lib/marianos_clones/netflix_clone.dart
Original file line number Diff line number Diff line change
Expand Up @@ -189,8 +189,11 @@ class _InitScreenState extends State<InitScreen> {
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
// ignore: deprecated_member_use
Colors.black.withOpacity(0.8),
// ignore: deprecated_member_use
Colors.black.withOpacity(0.42),
// ignore: deprecated_member_use
Colors.black.withOpacity(0.9),
],
begin: Alignment.topCenter,
Expand Down Expand Up @@ -910,8 +913,11 @@ class _LoginScreenState extends State<LoginScreen> {
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
// ignore: deprecated_member_use
Colors.black.withOpacity(0.8),
// ignore: deprecated_member_use
Colors.black.withOpacity(0.42),
// ignore: deprecated_member_use
Colors.black.withOpacity(0.9),
],
begin: Alignment.topCenter,
Expand All @@ -938,6 +944,7 @@ class _LoginScreenState extends State<LoginScreen> {
Container(
width: 450,
height: 675,
// ignore: deprecated_member_use
color: Colors.black.withOpacity(0.8),
padding: EdgeInsets.symmetric(
horizontal: breakpoint(size.width, 60, 40, 30),
Expand Down Expand Up @@ -1090,6 +1097,7 @@ class _LoginScreenState extends State<LoginScreen> {
SizedBox(height: 100),
Container(
width: size.width,
// ignore: deprecated_member_use
color: Colors.black.withOpacity(0.5),
height: 240,
child: Column(
Expand Down Expand Up @@ -1156,6 +1164,7 @@ class _LoginScreenState extends State<LoginScreen> {
height: 60,
width: 140,
decoration: BoxDecoration(
// ignore: deprecated_member_use
color: Colors.black.withOpacity(0.8),
border: Border.all(color: Color(0xFF333333), width: 2),
),
Expand Down Expand Up @@ -1202,6 +1211,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
// ignore: deprecated_member_use
Colors.black.withOpacity(0.8),
Colors.transparent,
],
Expand Down Expand Up @@ -1936,7 +1946,9 @@ class _BrowseScreenState extends State<BrowseScreen> {
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
// ignore: deprecated_member_use
Color(0xFF060606).withOpacity(_fadePercentage),
// ignore: deprecated_member_use
Color(0xFF141414).withOpacity(_fadePercentage),
],
begin: Alignment.topCenter,
Expand Down Expand Up @@ -1994,7 +2006,9 @@ class _BrowseScreenState extends State<BrowseScreen> {
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
// ignore: deprecated_member_use
Color(0xFF060606).withOpacity(0.8),
// ignore: deprecated_member_use
Color(0xFF141414).withOpacity(0.0),
],
begin: Alignment.topCenter,
Expand All @@ -2012,7 +2026,9 @@ class _BrowseScreenState extends State<BrowseScreen> {
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
// ignore: deprecated_member_use
Color(0xFF060606).withOpacity(_fadePercentage),
// ignore: deprecated_member_use
Color(0xFF141414).withOpacity(_fadePercentage),
],
begin: Alignment.topCenter,
Expand Down Expand Up @@ -2135,6 +2151,7 @@ class _BrowseScreenState extends State<BrowseScreen> {
height: 150,
decoration: BoxDecoration(
gradient: LinearGradient(
// ignore: deprecated_member_use
colors: [Color(0xFF141414).withOpacity(0), Color(0xFF141414)],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
Expand Down Expand Up @@ -2253,6 +2270,7 @@ class _BrowseScreenState extends State<BrowseScreen> {
height: 150,
decoration: BoxDecoration(
gradient: LinearGradient(
// ignore: deprecated_member_use
colors: [Color(0xFF141414).withOpacity(0), Color(0xFF141414)],
begin: Alignment.topCenter,
end: Alignment.bottomCenter,
Expand Down Expand Up @@ -2770,10 +2788,12 @@ class NetflixPainter extends CustomPainter {
..lineTo(legWidth + 70, 0)
..close();
final shadowPaint = Paint()
// ignore: deprecated_member_use
..color = Colors.black.withOpacity(anim.middleLegOpacity)
..maskFilter = MaskFilter.blur(BlurStyle.normal, 30);
final middleLegPaint = Paint()
..color =
// ignore: deprecated_member_use
NetflixColors.netflixDarkRed.withOpacity(anim.middleLegOpacity);
canvas.clipRect(middleLegClipPath);
canvas.drawPath(shadowPath, shadowPaint);
Expand Down Expand Up @@ -2860,6 +2880,7 @@ class NetflixPainter extends CustomPainter {
canvas.save();
if (anim.leftLegOpacity > 0) {
final leftLegPaint = Paint()
// ignore: deprecated_member_use
..color = NetflixColors.netflixDarkRed.withOpacity(anim.leftLegOpacity);

canvas.drawRect(
Expand All @@ -2883,6 +2904,7 @@ class NetflixPainter extends CustomPainter {
rect,
Paint()
..color = rainbowColors[i % rainbowColors.length]!
// ignore: deprecated_member_use
.withOpacity(1.0 - anim.leftLegOpacity)
..maskFilter = MaskFilter.blur(BlurStyle.normal, 3),
);
Expand Down
12 changes: 12 additions & 0 deletions examples/theme_editor/lib/marianos_clones/whatsapp_clone.dart
Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,7 @@ class ContactItem extends StatelessWidget {
overflow: TextOverflow.ellipsis,
style: TextStyle(
fontSize: 14,
// ignore: deprecated_member_use
color: Colors.black.withOpacity(0.6),
),
),
Expand Down Expand Up @@ -1037,9 +1038,11 @@ class _ChatItemState extends State<ChatItem> {
color: _lastMessageMine(
widget.conversation,
)
// ignore: deprecated_member_use
? Colors.black.withOpacity(0.6)
: _countUnread(widget.conversation) > 0
? Colors.black
// ignore: deprecated_member_use
: Colors.black.withOpacity(0.6),
),
),
Expand Down Expand Up @@ -1779,12 +1782,14 @@ class _ProfileScreenState extends State<ProfileScreen> {
SizedBox(height: 15),
Text(
'Your Name',
// ignore: deprecated_member_use
style: TextStyle(color: Colors.black.withOpacity(0.5)),
),
SizedBox(height: 20),
Text(
widget.user.name,
style: TextStyle(
// ignore: deprecated_member_use
color: Colors.black.withOpacity(0.8),
fontSize: 18,
),
Expand All @@ -1803,6 +1808,7 @@ class _ProfileScreenState extends State<ProfileScreen> {
const EdgeInsets.symmetric(horizontal: 30, vertical: 15),
child: Text(
'This is not your username or pin. This name will be visible to your WhatsApp contacts.',
// ignore: deprecated_member_use
style: TextStyle(color: Colors.black.withOpacity(0.5)),
),
),
Expand All @@ -1817,12 +1823,14 @@ class _ProfileScreenState extends State<ProfileScreen> {
SizedBox(height: 15),
Text(
'About',
// ignore: deprecated_member_use
style: TextStyle(color: Colors.black.withOpacity(0.5)),
),
SizedBox(height: 20),
Text(
widget.user.status,
style: TextStyle(
// ignore: deprecated_member_use
color: Colors.black.withOpacity(0.8),
fontSize: 18,
),
Expand Down Expand Up @@ -2037,7 +2045,9 @@ class ContactScreenState extends State<ContactScreen> {
decoration: BoxDecoration(
gradient: LinearGradient(
colors: [
// ignore: deprecated_member_use
Colors.black.withOpacity(0.0),
// ignore: deprecated_member_use
Colors.black.withOpacity(0.8)
],
begin: Alignment.topCenter,
Expand Down Expand Up @@ -2170,13 +2180,15 @@ class ContactScreenState extends State<ContactScreen> {
Text(
'About and phone number',
style: TextStyle(
// ignore: deprecated_member_use
color: Colors.black.withOpacity(0.5),
),
),
SizedBox(height: 15),
Text(
_user!.status,
style: TextStyle(
// ignore: deprecated_member_use
color: Colors.black.withOpacity(0.8),
),
),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
enableGPUValidationMode = "1"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
Expand Down
2 changes: 2 additions & 0 deletions lib/src/core/network/api_exceptions.dart
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,8 @@ extension WiredashApiWarnings on Response {
return warnings
.whereType<Map>()
.map((w) => WiredashApiWarning.tryParse(w))
// Switch to .nonNulls when minSdk is Dart 3.0
// ignore: deprecated_member_use
.whereNotNull()
.toList();
} catch (_) {
Expand Down
1 change: 0 additions & 1 deletion lib/src/core/support/not_a_widgets_app.dart
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
// ignore_for_file: join_return_with_assignment

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';

/// Wrapper with default that most widgets required that are now wrapped by a
Expand Down
2 changes: 2 additions & 0 deletions lib/src/core/theme/color_ext.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,8 @@ extension ColorBrightness on Color {
}

Brightness get brightness {
// Changed in Flutter 3.26 https://github.com/flutter/engine/pull/54737
// ignore: deprecated_member_use
final grayscale = (0.299 * red) + (0.587 * green) + (0.114 * blue);

if (grayscale > 128) {
Expand Down
11 changes: 11 additions & 0 deletions lib/src/core/theme/wiredash_theme_data.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ class WiredashThemeData {
Color? secondaryColor,
required Brightness brightness,
}) {
// Changed in Flutter 3.26 https://github.com/flutter/engine/pull/54737
// ignore: deprecated_member_use
if (secondaryColor?.value == primaryColor.value) {
secondaryColor = null;
}
Expand Down Expand Up @@ -255,6 +257,8 @@ class WiredashThemeData {
}
final merged =
Color.lerp(primaryBackgroundColor, secondaryBackgroundColor, 0.5)!;
// Changed in Flutter 3.26 https://github.com/flutter/engine/pull/54737
// ignore: deprecated_member_use
final palette = CorePalette.of(merged.value);

final tone = isLight ? 10 : 100;
Expand All @@ -269,6 +273,8 @@ class WiredashThemeData {
}
final merged =
Color.lerp(primaryBackgroundColor, secondaryBackgroundColor, 0.5)!;
// Changed in Flutter 3.26 https://github.com/flutter/engine/pull/54737
// ignore: deprecated_member_use
final palette = CorePalette.of(merged.value);

final tone = isLight ? 40 : 70;
Expand Down Expand Up @@ -301,6 +307,7 @@ class WiredashThemeData {
}

Color get secondaryTextOnSurfaceColor {
// ignore: deprecated_member_use
return _primaryTone.onSurface.withOpacity(0.8);
}

Expand Down Expand Up @@ -894,13 +901,15 @@ class SurfaceBasedTextStyle {
theme,
theme.textTheme.body2Medium,
'body2Medium',
// ignore: deprecated_member_use
colorMutation: (color) => color.withOpacity(0.7),
);

late final SurfaceSelector body2Small = SurfaceSelector(
theme,
theme.textTheme.body2Small,
'body2Small',
// ignore: deprecated_member_use
colorMutation: (color) => color.withOpacity(0.7),
);

Expand Down Expand Up @@ -1068,6 +1077,8 @@ enum DeviceClass {
/// Based on the theory in https://m3.material.io/styles/color/dynamic-color/user-generated-color
class MaterialColorTone {
MaterialColorTone(this.baseColor, this.brightness)
// Changed in Flutter 3.26 https://github.com/flutter/engine/pull/54737
// ignore: deprecated_member_use
: palette = CorePalette.of(baseColor.value);
final Color baseColor;
final CorePalette palette;
Expand Down
2 changes: 2 additions & 0 deletions lib/src/core/widgets/backdrop/fake_app_status_bar.dart
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ class FakeAppStatusBar extends StatelessWidget {
children: [
Icon(
Wirecons.cheveron_up,
// ignore: deprecated_member_use
color: blackOrWhite.withOpacity(0.80),
size: 16,
),
Expand All @@ -59,6 +60,7 @@ class FakeAppStatusBar extends StatelessWidget {
const SizedBox(width: 16),
Icon(
Wirecons.cheveron_up,
// ignore: deprecated_member_use
color: blackOrWhite.withOpacity(0.80),
size: 16,
),
Expand Down
Loading

0 comments on commit e77353d

Please sign in to comment.