toValue method

Object? toValue()

Converts this Constant to the value it represents.

Implementation

Object? toValue() => switch (this) {
  NullConstant() => null,
  PrimitiveConstant p => p.value,
  ListConstant<Constant> l => l.value.map((c) => c.toValue()).toList(),
  MapConstant<Constant> m => m.value.map(
    (key, value) => MapEntry(key, value.toValue()),
  ),
  InstanceConstant i => i.fields.map(
    (key, value) => MapEntry(key, value.toValue()),
  ),
};