【问题标题】:The method 'DefaultCacheManager' isn't defined for the class 'WallpaperImages'. flutter没有为类“WallpaperImages”定义方法“DefaultCacheManager”。扑
【发布时间】:2020-07-12 17:13:35
【问题描述】:

var file = await DefaultCacheManager().getSingleFile(url);

我无法使用此行获取 url 的文件路径

帮帮我

Compiler message:
lib/main.dart:59:22: Error: The method 'DefaultCacheManager' isn't defined for the class 'WallpaperImages'.
 - 'WallpaperImages' is from 'package:flutter_app_sample/main.dart' ('lib/main.dart').
Try correcting the name to the name of an existing method, or defining a method named 'DefaultCacheManager'.
    var file = await DefaultCacheManager().getSingleFile(url);
                     ^^^^^^^^^^^^^^^^^^^

【问题讨论】:

    标签: flutter naming


    【解决方案1】:

    使用包https://pub.dev/packages/flutter_cache_manager
    你可以import

    import 'package:flutter_cache_manager/flutter_cache_manager.dart';
    

    pubspec.yaml 中添加flutter_cache_manager

    dependencies:
      flutter:
        sdk: flutter
      flutter_cache_manager: any
    

    【讨论】:

      猜你喜欢
      • 2021-10-24
      • 2021-09-02
      • 1970-01-01
      • 2019-06-24
      • 2021-01-30
      • 2020-09-10
      • 2019-05-23
      • 1970-01-01
      • 2022-11-21
      相关资源
      最近更新 更多