theme_model.dart 1.38 KB
import 'package:flutter/material.dart';

class ThemeModel {
  String colorName;
  String colorValueS; //渐变色起始值
  String colorValueM; //渐变色中间值
  String colorValueE; //渐变色结束值
  List<ThemeSunModel> urls; //当前色值下的模版链接集合

  ThemeModel();

  ThemeModel.fromJson(Map<String, dynamic> json) {
    colorName = json['color_name'];
    colorValueS = json['color_value_s'];
    colorValueM = json['color_value_m'];
    colorValueE = json['color_value_e'];
    urls = <ThemeSunModel>[];
    if (json['urls'] != null) {
      json['urls'].forEach((v) {
        if (v is ThemeSunModel) {
          urls.add(v);
        } else {
          urls.add(new ThemeSunModel.fromJson(v));
        }
      });
    }
  }

  Map<String, dynamic> toJson() => <String, dynamic>{
        "color_name": colorName,
        "color_value_s": colorValueS,
        "color_value_m": colorValueM,
        "color_value_e": colorValueE,
        'urls': urls
      };
}

class ThemeSunModel {
  String name; //模版名称
  String id; //模版编号
  String url; //当前色值下的模版链接

  ThemeSunModel();

  factory ThemeSunModel.fromJson(Map<String, dynamic> json) => ThemeSunModel()
    ..name = json["name"]
    ..id = json["id"]
    ..url = json["url"];

  Map<String, dynamic> toJson() => <String, dynamic>{
        "name": name,
        "id": id,
        "url": url,
      };
}