before static method

String before(
  1. String subject,
  2. String search
)

Returns the portion of subject before the first occurrence of search.

Implementation

static String before(String subject, String search) {
  if (search.isEmpty) return subject;
  final index = subject.indexOf(search);
  if (index == -1) return subject;
  return subject.substring(0, index);
}