parsePadding function

dynamic parsePadding(
  1. MetaObject context,
  2. EdgeInsets defaultvalue,
  3. TreeNode node,
  4. String property
)

Implementation

parsePadding(MetaObject context, EdgeInsets defaultvalue, TreeNode node,
    String property) {
  var obj = parseObject(context, defaultvalue, node, property);
  if (obj == null) {
    return defaultvalue;
  }
  if(obj is String) {
    String str = obj;
    var parts = obj.split(',');
    if (parts.length == 4) {
      double p1 = double.parse(parts[0]);
      double p2 = double.parse(parts[1]);
      double p3 = double.parse(parts[2]);
      double p4 = double.parse(parts[3]);
      return EdgeInsets.fromLTRB(p1, p2, p3, p4);
    } else if (parts.length == 2) {
      double w = double.parse(parts[0]);
      double h = double.parse(parts[1]);
      return EdgeInsets.fromLTRB(w, h, w, h);
    } else if (parts.length == 1) {
      return EdgeInsets.all(double.parse(parts[0]));
    } else {
      return defaultvalue;
    }
  }else if(obj is Color){
    return obj;
  }
  return defaultvalue;
}