chore: Fix dart deprecation messages

This commit is contained in:
PartyDonut 2025-01-05 13:53:59 +01:00
parent 607dea3de1
commit 39a7537116
81 changed files with 258 additions and 195 deletions

View file

@ -2,6 +2,37 @@ import 'package:flutter/material.dart';
import 'package:fladder/util/localization_helper.dart';
Color? colorFromJson(dynamic color) {
if (color == null) return null;
if (color is Map<String, dynamic>) {
return Color.from(
alpha: color['alpha'] ?? 1.0,
red: color['red'] ?? 1.0,
green: color['green'] ?? 1.0,
blue: color['blue'] ?? 1.0,
);
}
// Deprecated format (integer value)
if (color is int) {
return Color(color);
}
return null;
}
extension ColorExtensions on Color {
Map<String, dynamic> get toMap {
return {
'alpha': a,
'red': r,
'green': g,
'blue': b,
};
}
}
extension DynamicSchemeVariantExtension on DynamicSchemeVariant {
String label(BuildContext context) => switch (this) {
DynamicSchemeVariant.tonalSpot => context.localized.schemeSettingsTonalSpot,