This commit is contained in:
julian-CStack 2023-04-25 07:28:10 -06:00
parent 4ed34ad50f
commit c206ed3e77
2 changed files with 38 additions and 34 deletions

View file

@ -59,15 +59,22 @@ class StackTheme {
// ==== gradientBackground =====================================================
@ignore
Gradient get gradientBackground =>
Gradient? get gradientBackground {
if (gradientBackgroundString == null) {
_gradientBackground = null;
} else {
_gradientBackground ??= GradientExt.fromJson(
Map<String, dynamic>.from(
jsonDecode(gradientBackgroundString) as Map,
jsonDecode(gradientBackgroundString!) as Map,
),
);
}
return _gradientBackground;
}
@ignore
Gradient? _gradientBackground;
final String gradientBackgroundString;
final String? gradientBackgroundString;
// ==== boxShadows =====================================================
@ -1643,7 +1650,9 @@ class StackTheme {
parseColor(json["colors"]["background"]["background"] as String),
backgroundAppBarInt: parseColor(
json["colors"]["background"]["backgroundAppBar"] as String),
gradientBackgroundString: jsonEncode(json["gradients"] as Map),
gradientBackgroundString: json["gradients"]["background"] == null
? null
: jsonEncode(json["gradients"]["background"] as Map),
standardBoxShadowString:
jsonEncode(json["box_shadows"]["standard"] as Map),
homeViewButtonBarBoxShadowString:

View file

@ -14,8 +14,8 @@ final map = {
"background": "0xFF848383",
},
"gradients": {
"gradientBackground": {
"gradientType": "linear",
"background": {
"type": "linear",
"begin": {
"x": 0.0,
"y": 1.0,
@ -34,10 +34,8 @@ final map = {
extension GradientExt on Gradient {
static Gradient fromJson(Map<String, dynamic> json) {
print("THIS GRADIENTS IS ${json.isEmpty}");
if (!json.isEmpty) {
switch (json["background"]["type"]) {
case "Linear":
switch (json["type"]) {
case "linear":
final colorStrings =
List<String>.from(json["background"]["colors"] as List);
return LinearGradient(
@ -62,7 +60,4 @@ extension GradientExt on Gradient {
throw ArgumentError("Invalid json gradient: $json");
}
}
throw ArgumentError("Invalid json gradient: $json");
// if ()
}
}