fromPath static method

PublicationFormat? fromPath(
  1. String path, {
  2. required String mimetype,
})

Finds the PublicationFormat of the file at the given path, using an optionally provided mimetype.

Implementation

static PublicationFormat? fromPath(String path, {required String mimetype}) {
  String? extension = p.extension(path);
  if (extension.length > 1) {
    // Removes the dot.
    extension = extension.substring(1);
  } else {
    extension = null;
  }

  return PublicationFormat.fromMIMEType(mimetype, fileExtension: extension);
}