file_data_source_util.dart 653 B

123456789101112131415161718192021222324252627
  1. import '../../data/bean/upload_info.dart';
  2. /// 文件资源工具类
  3. class FileDataSourceUtil {
  4. /// 是否网络图片优先
  5. static final bool isNetworkPriority = false;
  6. /// 获取文件数据源的src
  7. static String getFileDataSourceSrc(UploadInfo info) {
  8. String remoteUrl = info.fileUrl ?? "";
  9. String localFilePath = info.filePath ?? "";
  10. // 优先使用远程Url,否则使用文件的绝对路径
  11. if (isNetworkPriority) {
  12. String src;
  13. if (remoteUrl.isNotEmpty) {
  14. src = remoteUrl;
  15. } else {
  16. src = localFilePath;
  17. }
  18. return src;
  19. } else {
  20. return localFilePath;
  21. }
  22. }
  23. }