replace function

String replace(
  1. String searchValue,
  2. String replaceValue,
  3. String s
)

Replaces the first occurrence of a substring.

print(replace('l', 'w', 'hello')); // Outputs: 'hewlo'

Implementation

String replace(String searchValue, String replaceValue, String s) =>
    s.replaceFirst(RegExp(searchValue), replaceValue);