rightOf method Null safety

String? rightOf(
  1. String char
)

Returns the right side of the String starting from char

Example

 String s = 'peanutbutter';
 String foo = s.rightOf('peanut'); // returns 'butter'

Implementation

String? rightOf(String char) {
  if (this == null) {
    return null;
  }
  if (this!.isEmpty) {
    return this;
  }

  int index = this!.indexOf(char);
  return this!.substring(index + char.length, this!.length);
}