base.dart 720 B

123456789101112131415161718192021222324252627282930313233343536
  1. import 'package:fis_common/logger/logger.dart';
  2. import 'package:flutter/foundation.dart';
  3. import 'package:vid/us/vid_us_image.dart';
  4. /// Vid图像获取
  5. abstract class VidImageFetcherBase {
  6. late final String _url;
  7. /// 图像缓存(未释放时保持)
  8. @protected
  9. VidUsImage? cache;
  10. VidImageFetcherBase(String url) {
  11. _url = url;
  12. }
  13. /// vid链接
  14. String get url => _url;
  15. /// 获取图像
  16. Future<VidUsImage?> fetch() async {
  17. try {
  18. cache ??= await innerFetch();
  19. return cache!;
  20. } catch (e) {
  21. logger.e('VidImageFetcherBase - fetch vid image fail', e);
  22. }
  23. return null;
  24. }
  25. @protected
  26. Future<VidUsImage?> innerFetch();
  27. /// 释放资源
  28. void dispose();
  29. }