splitMapJoin method Null safety

String splitMapJoin (
  1. Pattern pattern,
  2. {String onMatch(
    1. Match
  3. String onNonMatch(
    1. String

Splits the string, converts its parts, and combines them into a new string.

pattern is used to split the string into parts and separating matches.

Each match is converted to a string by calling onMatch. If onMatch is omitted, the matched string is used.

Each non-matched part is converted by a call to onNonMatch. If onNonMatch is omitted, the non-matching part is used.

Then all the converted parts are combined into the resulting string.

'Eats shoots leaves'.splitMapJoin((new RegExp(r'shoots')),
    onMatch:    (m) => '${m.group(0)}',
    onNonMatch: (n) => '*'); // *shoots*


String splitMapJoin(Pattern pattern,
    {String Function(Match)? onMatch, String Function(String)? onNonMatch});