evaluateObject static method
Object?
evaluateObject(
- Object? context,
- Object? value, {
- bool asElement = true,
- bool resolveDSX = true,
- QueryElementProvider? elementProvider,
- IntlMessageResolver? intlMessageResolver,
Implementation
static Object? evaluateObject(Object? context, Object? value,
{bool asElement = true,
bool resolveDSX = true,
QueryElementProvider? elementProvider,
IntlMessageResolver? intlMessageResolver}) {
if (value == null) return null;
if (value is String) {
return value;
} else if (value is bool) {
return value;
} else if (value is num) {
return value;
} else if (value is List) {
return value
.map((e) => evaluateObject(context, e,
asElement: asElement,
elementProvider: elementProvider,
intlMessageResolver: intlMessageResolver))
.toList();
} else if (value is Map) {
return Map.from(value.map((k, v) => MapEntry(
evaluateObject(context, k,
asElement: asElement,
elementProvider: elementProvider,
intlMessageResolver: intlMessageResolver),
evaluateObject(context, v,
asElement: asElement,
elementProvider: elementProvider,
intlMessageResolver: intlMessageResolver))));
} else if (value is DSX) {
if (resolveDSX) {
var resolver = value.createResolver();
var res = asElement
? resolver.resolveElement(
elementProvider: elementProvider,
intlMessageResolver: intlMessageResolver)
: resolver.resolveValue(
elementProvider: elementProvider,
intlMessageResolver: intlMessageResolver);
return evaluateObject(context, res,
asElement: asElement,
resolveDSX: resolveDSX,
elementProvider: elementProvider,
intlMessageResolver: intlMessageResolver);
} else {
return value.toString();
}
} else if (value is Function(Map? a)) {
var res = value(context as Map<dynamic, dynamic>?);
return evaluateObject(context, res,
asElement: asElement,
elementProvider: elementProvider,
intlMessageResolver: intlMessageResolver);
} else if (value is Function(Object? a)) {
var res = value(context);
return evaluateObject(context, res,
asElement: asElement,
elementProvider: elementProvider,
intlMessageResolver: intlMessageResolver);
} else if (value is Function()) {
var res = value();
return evaluateObject(context, res,
asElement: asElement,
elementProvider: elementProvider,
intlMessageResolver: intlMessageResolver);
} else {
return value;
}
}