literal function Null safety
- Object? literal,
- {Expression onError( )?}
Converts a runtime Dart literal value into an Expression.
Unsupported inputs invoke the onError
callback.
Implementation
Expression literal(Object? literal, {Expression Function(Object)? onError}) {
if (literal is bool) {
return literalBool(literal);
}
if (literal is num) {
return literalNum(literal);
}
if (literal is String) {
return literalString(literal);
}
if (literal is List) {
return literalList(literal);
}
if (literal is Set) {
return literalSet(literal);
}
if (literal is Map) {
return literalMap(literal);
}
if (literal == null) {
return literalNull;
}
if (onError != null) {
return onError(literal);
}
throw UnsupportedError('Not a supported literal type: $literal.');
}