getFileNameWithoutExtension function

String getFileNameWithoutExtension(
  1. String path
)

Implementation

String getFileNameWithoutExtension(String path) {
  // Get the file name from the path
  String fileName = File(path).uri.pathSegments.last;

  // Remove the extension
  return fileName.contains('.')
      ? fileName.substring(0, fileName.lastIndexOf('.'))
      : fileName;
}