when<T> method
T
when<T>({
- required T string(
- StringValueNode
- required T int_(
- IntValueNode
- required T float(
- FloatValueNode
- required T boolean(
- BooleanValueNode
- required T object(
- ObjectValueNode
- required T list(
- ListValueNode
- required T enum_(
- EnumValueNode
- required T null_(
- NullValueNode
- required T variable(
- VariableNode
Executes the given callback when this
is of the type parameter
Implementation
T when<T>({
required T Function(ast.StringValueNode) string,
required T Function(ast.IntValueNode) int_,
required T Function(ast.FloatValueNode) float,
required T Function(ast.BooleanValueNode) boolean,
required T Function(ast.ObjectValueNode) object,
required T Function(ast.ListValueNode) list,
required T Function(ast.EnumValueNode) enum_,
required T Function(ast.NullValueNode) null_,
required T Function(ast.VariableNode) variable,
}) {
final v = this;
if (v is ast.StringValueNode) return string(v);
if (v is ast.IntValueNode) return int_(v);
if (v is ast.FloatValueNode) return float(v);
if (v is ast.BooleanValueNode) return boolean(v);
if (v is ast.ObjectValueNode) return object(v);
if (v is ast.ListValueNode) return list(v);
if (v is ast.EnumValueNode) return enum_(v);
if (v is ast.NullValueNode) return null_(v);
if (v is ast.VariableNode) return variable(v);
throw Error();
}