copyWith method

Token copyWith({
  1. String? path,
  2. String? variableName,
  3. String? type,
  4. dynamic value,
  5. Map<String, dynamic>? extensions,
})

Returns a copy of this token with the given values. If the path is set, the variable name will be updated as well.

Implementation

Token copyWith({
  String? path,
  String? variableName,
  String? type,
  dynamic value,
  Map<String, dynamic>? extensions,
}) {
  if (path != null && variableName == null) {
    variableName = _getVariableName(path, name);
  }

  return Token(
    name: name,
    type: type ?? this.type,
    value: value ?? this.value,
    path: path ?? this.path,
    extensions: extensions ?? this.extensions,
    variableName: variableName ?? this.variableName,
  );
}