RealFilePre.dart 1.1 KB

12345678910111213141516171819202122232425262728293031323334
  1. import 'dart:io';
  2. import 'package:flutter/cupertino.dart';
  3. import 'package:neofilemanager/Item/Common.dart';
  4. import 'package:neofilemanager/Item/Preview/FilePre.dart';
  5. class RealFilePre extends FilePre {
  6. Common common;
  7. FileSystemEntity file;
  8. String extension;
  9. double iconHeight = 30.0;
  10. double iconWidth = 30.0;
  11. double fileHeight = 50.0;
  12. double fileWidth = 70.0;
  13. RealFilePre(
  14. this.common, this.file, this.extension, this.fileHeight, this.fileWidth);
  15. Widget build(BuildContext context) {
  16. print('开始加载'+file.path);
  17. // 如果是图片类型的文件返回图片,否则返回文件图标
  18. if (extension == '.png' || extension == '.jpg' || extension == '.jpeg' || extension == '.gif') {
  19. Image tempImage=Image.file(file, height: fileHeight, width: fileWidth, fit: BoxFit.cover);
  20. print('加载完毕'+file.path);
  21. return ClipRRect(
  22. borderRadius: BorderRadius.circular(10),
  23. child: tempImage,
  24. );
  25. } else {
  26. return Image.asset( common.selectIcon(extension), height: iconHeight, width: iconWidth,
  27. );
  28. }
  29. }
  30. }