Style.fromJson constructor

Style.fromJson(
  1. Map<String, dynamic> json
)

Constructs the object from json

Implementation

Style.fromJson(Map<String, dynamic> json) {
  bool isPropertySet = false;
  if (json['breakPoint'] != null) {
    breakPoint = json['breakPoint'] as int;
    isPropertySet = true;
  }

  if (json['default'] != null) {
    if (json['default'] is Map<String, dynamic>) {
      defaultStyleRule = StyleRule.fromJson(json['default']);
      isPropertySet = true;
    } else {
      Util.showWarning(
          "`default` should be an object of Map<String, dynamic>");
    }
  }

  if (json['defaultStyleRule'] != null) {
    if (json['defaultStyleRule'] is Map<String, dynamic>) {
      defaultStyleRule = StyleRule.fromJson(json['defaultStyleRule']);
      isPropertySet = true;
    } else {
      Util.showWarning(
          "`defaultStyleRule` should be an object of Map<String, dynamic>");
    }
  }

  if (json['rules'] != null) {
    if (json['rules'] is List<Map<String, dynamic>>) {
      List<Map<String, dynamic>> ruleList = json['rules'];
      for (Map<String, dynamic> item in ruleList) {
        rules?.add(TypedStyleRule.fromJson(item));
        isPropertySet = true;
      }
    } else {
      Util.showWarning(
          "`rules` should be an object of List<Map<String, dynamic>>");
    }
  }
  if (!isPropertySet) {
    Util.showWarning("No valid properties found in given map for Style.");
  }
}