maybeFromDynamic static method

Conditional? maybeFromDynamic(
  1. dynamic map
)

Creates a new Conditional from a Map-like dynamic value. The map must be a Map or a Map-like object that supports the [String] operator.

This expect the format of the object to be as follows:

{
  "conditions": <Conditional[]>,
  "mode": <String>,
  "values": <Map<String, dynamic>>
}

Either conditions or values must be set, but not both. The mode defaults to EvaluationMode.and if not set.

See also:

Implementation

static Conditional? maybeFromDynamic(dynamic map) {
  Conditional? result;

  if (map != null) {
    result = Conditional(
      conditions: JsonClass.maybeFromDynamicList(
        map['conditions'],
        fromDynamic,
      ),
      mode: EvaluationMode.fromCode(map['mode']) ?? EvaluationMode.and,
      values: map['values'] == null
          ? null
          : Map<String, dynamic>.from(map['values']),
    );
  }

  return result;
}