import 'dart:io'; import 'package:path_provider/path_provider.dart'; class ImgCachePath{ factory ImgCachePath() => _getInstance(); static ImgCachePath get instance => _getInstance(); static ImgCachePath? _instance; String? _path; String get path => _path ?? ""; ImgCachePath._internal(){ fileFromDocsDir(); } fileFromDocsDir() async { Directory tempDir = await getTemporaryDirectory(); Directory directory = new Directory('${tempDir.path}/ImgCache'); if (!directory.existsSync()) { directory.createSync(); } _path = directory.path; } static ImgCachePath _getInstance(){ if (_instance == null) { _instance = ImgCachePath._internal(); } return _instance!; } }