JsonKeyMutate.fromJsonKeyParamaString constructor

JsonKeyMutate.fromJsonKeyParamaString(
  1. String theString
)

Implementation

factory JsonKeyMutate.fromJsonKeyParamaString(String theString) {
  theString = getParameterString(theString);

  var newList = theString
      .split(',')
      .map((e) => e.split(':'))
      .where((element) => element.length > 1)
      .map(
    (e) {
      var theValue = e.last.trim();
      var expression = Expression.parse(theValue);
      final evaluator = const ExpressionEvaluator();
      var theMap = [
        e.first.trim(),
        evaluator.eval(expression, Map()),
      ];

      return theMap;
    },
  );
  Map<String, dynamic> newMap = Map<String, dynamic>();
  newMap.clear();
  newList.forEach((e) {
    newMap.putIfAbsent(e.first, () => e.last);
  });
  return JsonKeyMutate(
    defaultValue: newMap['defaultValue'],
    disallowNullValue: newMap['disallowNullValue'],
    fromJson: newMap['fromJson'],
    ignore: newMap['ignore'],
    includeIfNull: newMap['includeIfNull'],
    name: newMap['name'],
    nullable: newMap['nullable'],
    required: newMap['required'],
    toJson: newMap['toJson'],
    unknownEnumValue: newMap['unknownEnumValue'],
  );
}