fileExtension property

String get fileExtension

Gets the file extension including the dot.

Returns the file extension with the leading dot. For example, if the file path is '/home/user/document.pdf', this returns '.pdf'.

Example:

final file = File('/downloads/image.png');
print(file.fileExtension); // '.png'

Implementation

String get fileExtension {
  return p.extension(path);
}