getFileExtension static method

String getFileExtension(
  1. String filePath
)

Get file extension from file path

filePath - The file path Returns file extension without dot

Implementation

static String getFileExtension(String filePath) {
  final lastDot = filePath.lastIndexOf('.');
  if (lastDot == -1 || lastDot == filePath.length - 1) return '';
  return filePath.substring(lastDot + 1).toLowerCase();
}