insert method
Inserts the given text at the specified index in the original string.
This method returns a new string with the text inserted at the index position.
Example:
String original = "HelloWorld";
String result = original.insert(" ", 5);
print(result); // Outputs: "Hello World"
Throws a RangeError if index is out of bounds.
Implementation
String insert(String text, int index) =>
substring(0, index) + text + substring(index);