viewFile static method

dynamic viewFile({
  1. required FileData fileData,
  2. dynamic onView(
    1. FileData fileData
    )?,
})

function file view

Implementation

static viewFile(
    {required FileData fileData, Function(FileData fileData)? onView}) {
  try {
    String path = (!Files._isNullOREmpty(fileData.path))
        ? fileData.path
        : fileData.otherDevicePath;
    if (!Files._isNullOREmpty(path)) {
      if (onView != null) {
        onView(fileData);
      } else {
        if (Files.isHttpPath(path)) {
          Open.browser(url: path);
        } else {
          Open.localFile(filePath: path);
        }
      }
    } else {
      dev.log(Files._fileNotFound);
    }
  } catch (e) {
    dev.log(Files._fileCouldNotLoad);
  }
}