insertStringAtPosition method

String insertStringAtPosition({
  1. required String input,
  2. required String positionOf,
})

Inserts a given input string at the position right after the first occurrence of an opening curly bracket ('{').

Returns the modified string after inserting the input string.

Throws an Exception if no opening curly bracket is found in the string.

Implementation

String insertStringAtPosition({
  required String input,
  required String positionOf,
}) {
  final position = indexOf(positionOf) + 1;
  return substring(0, position) + input + substring(position);
}