How to decapitalize an argument in a Live Template in IntelliJ

129 Views Asked by At

In my project, I have many serialization classes and, to make the classes more readable, I'm standardizing them, with an argument which has the same name of the $class$, that is $argName$:

@immutable
class $class$_Serialize extends Serialize<$class$> {
  final $class$ $argName$;

  $class$_Serialize(this.$argName$);

  @override
  Map<String, Object> run() => $serialize$
}

In the Live Template above, the annoyance is that I have to retype $argName$ instead of the template simply decapitalizing $class$. How would I tie $argName$ to the decapitalization of $class$ in IntelliJ?

I've already tried to mess around with editing the variables and adding the decaptialize() function in the expression column, but so far haven't had much success. It was something like this:

Attempt at using decapitalize()

1

There are 1 best solutions below

2
On BEST ANSWER

You are using the wrong syntax for the decapitalize function. It should look like this:

decapitalize(class)

Note that there are no $ signs around the class in the function argument.