getPathExtension function

String? getPathExtension(
  1. String? path
)

Returns the File extension of a path.

Implementation

String? getPathExtension(String? path) {
  if (path == null) return null;
  path = path.trim();
  if (path.isEmpty) return null;

  var idx = path.lastIndexOf('.');
  if (idx < 0) return null;
  var ext = path.substring(idx + 1);
  return ext.isNotEmpty ? ext : null;
}