import 'package:flutter/widgets.dart';

/// 元素对象，设置列表项等
class ComponentModel {
  String title; // 标题
  String content; // 内容
  String extra; // 其他文字
  String url; // 地址
  String imgUrl; // 图片地址
  int typeId; //类型
  Widget page; // 跳转页面

  ComponentModel(
      {this.title,
      this.content,
      this.extra,
      this.url,
      this.imgUrl,
      this.typeId,
      this.page});

  ComponentModel.fromJson(Map<String, dynamic> json)
      : title = json['title'],
        content = json['content'],
        extra = json['extra'],
        url = json['url'],
        imgUrl = json['imgUrl'];

  Map<String, dynamic> toJson() => {
        'title': title,
        'content': content,
        'extra': extra,
        'url': url,
        'imgUrl': imgUrl,
      };

  @override
  String toString() {
    StringBuffer sb = new StringBuffer('{');
    sb.write(",\"title\":\"$title\"");
    sb.write(",\"content\":\"$content\"");
    sb.write(",\"extra\":\"$extra\"");
    sb.write(",\"url\":\"$url\"");
    sb.write(",\"imgUrl\":\"$imgUrl\"");
    sb.write('}');
    return sb.toString();
  }
}
