getPath static method

String? getPath(
  1. Directory? dir, {
  2. String? category,
  3. String? fileName,
  4. String? format,
})

get path. dir category 分类,例如:Download,Pictures, Music等等 fileName 文件名 format 文件格式,如果文件名包含格式,则不需要

Implementation

static String? getPath(
  Directory? dir, {
  String? category,
  String? fileName,
  String? format,
}) {
  if (dir == null) return null;
  StringBuffer sb = StringBuffer("${dir.path}");
  if (category != null) sb.write("/$category");
  if (fileName != null) sb.write("/$fileName");
  if (format != null) sb.write(".$format");
  return sb.toString();
}