2023-05-26 21:21:16 +00:00
|
|
|
/*
|
|
|
|
* This file is part of Stack Wallet.
|
|
|
|
*
|
|
|
|
* Copyright (c) 2023 Cypher Stack
|
|
|
|
* All Rights Reserved.
|
|
|
|
* The code is distributed under GPLv3 license, see LICENSE file for details.
|
|
|
|
* Generated by Cypher Stack on 2023-05-26
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2023-04-18 16:46:04 +00:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:stackwallet/utilities/extensions/impl/string.dart';
|
|
|
|
|
|
|
|
extension GradientExt on Gradient {
|
|
|
|
static Gradient fromJson(Map<String, dynamic> json) {
|
2023-04-25 13:58:51 +00:00
|
|
|
switch (json["background"]["type"]) {
|
|
|
|
case "Linear":
|
|
|
|
final colorStrings =
|
|
|
|
List<String>.from(json["background"]["colors"] as List);
|
|
|
|
return LinearGradient(
|
|
|
|
begin: Alignment(
|
|
|
|
json["background"]["begin"]["x"] as double,
|
|
|
|
json["background"]["begin"]["y"] as double,
|
|
|
|
),
|
|
|
|
end: Alignment(
|
|
|
|
json["background"]["end"]["x"] as double,
|
|
|
|
json["background"]["end"]["y"] as double,
|
|
|
|
),
|
|
|
|
colors: colorStrings
|
|
|
|
.map(
|
|
|
|
(e) => Color(
|
|
|
|
e.toBigIntFromHex.toInt(),
|
|
|
|
),
|
|
|
|
)
|
|
|
|
.toList(),
|
|
|
|
);
|
2023-04-18 16:46:04 +00:00
|
|
|
|
2023-04-25 13:58:51 +00:00
|
|
|
default:
|
|
|
|
throw ArgumentError("Invalid json gradient: $json");
|
2023-04-18 16:46:04 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|