getPathFileName function

String? getPathFileName(
  1. String? path
)

Returns the File name of a path.

Implementation

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

  var idx = path.lastIndexOf(RegExp(r'[/\\]'));
  if (idx < 0) return path;

  var name = path.substring(idx + 1);
  return name.isNotEmpty ? name : null;
}