From 92e268e838690bf337e9c9a2ace752207a0ce75a Mon Sep 17 00:00:00 2001 From: Carapacik Date: Wed, 24 May 2023 10:29:03 +0300 Subject: [PATCH 01/27] Upgrade to Dart 3 --- flutter_cache_manager/.gitignore | 83 ++++--------------- .../lib/generated_plugin_registrant.dart | 16 ---- flutter_cache_manager/example/lib/main.dart | 6 +- .../lib/plugin_example/download_page.dart | 10 +-- .../lib/plugin_example/file_info_widget.dart | 12 +-- .../floating_action_button.dart | 5 +- .../plugin_example/progress_indicator.dart | 4 +- .../linux/flutter/generated_plugins.cmake | 8 ++ .../Flutter/GeneratedPluginRegistrant.swift | 2 +- flutter_cache_manager/example/pubspec.yaml | 10 +-- .../flutter/generated_plugin_registrant.cc | 6 +- .../windows/flutter/generated_plugins.cmake | 8 ++ flutter_cache_manager/pubspec.yaml | 18 ++-- 13 files changed, 69 insertions(+), 119 deletions(-) delete mode 100644 flutter_cache_manager/example/lib/generated_plugin_registrant.dart diff --git a/flutter_cache_manager/.gitignore b/flutter_cache_manager/.gitignore index 09941d42..24476c5d 100644 --- a/flutter_cache_manager/.gitignore +++ b/flutter_cache_manager/.gitignore @@ -1,6 +1,5 @@ # Miscellaneous *.class -*.lock *.log *.pyc *.swp @@ -8,9 +7,8 @@ .atom/ .buildlog/ .history -.project .svn/ -bin/ +migrate_working_dir/ # IntelliJ related *.iml @@ -18,78 +16,29 @@ bin/ *.iws .idea/ -# Android Studio related -android/.classpath -android/.settings/ - -# Visual Studio Code related -.vscode/ - -# Flutter repo-specific -/bin/cache/ -/bin/mingit/ -/dev/benchmarks/mega_gallery/ -/dev/bots/.recipe_deps -/dev/bots/android_tools/ -/dev/docs/doc/ -/dev/docs/lib/ -/dev/docs/pubspec.yaml -/packages/flutter/coverage/ -version +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ # Flutter/Dart/Pub related **/doc/api/ +**/ios/Flutter/.last_build_id .dart_tool/ .flutter-plugins +.flutter-plugins-dependencies .packages .pub-cache/ .pub/ -build/ -flutter_*.png -linked_*.ds -unlinked.ds -unlinked_spec.ds -flutter_export_environment.sh +/build/ -# Android related -**/android/**/gradle-wrapper.jar -**/android/.gradle -**/android/captures/ -**/android/gradlew -**/android/gradlew.bat -**/android/local.properties -**/android/**/GeneratedPluginRegistrant.java +# Symbolication related +app.*.symbols -# iOS/XCode related -**/ios/**/*.mode1v3 -**/ios/**/*.mode2v3 -**/ios/**/*.moved-aside -**/ios/**/*.pbxuser -**/ios/**/*.perspectivev3 -**/ios/**/*sync/ -**/ios/**/.sconsign.dblite -**/ios/**/.tags* -**/ios/**/.vagrant/ -**/ios/**/DerivedData/ -**/ios/**/Icon? -**/ios/**/Pods/ -**/ios/**/.symlinks/ -**/ios/**/profile -**/ios/**/xcuserdata -**/ios/.generated/ -**/ios/Flutter/App.framework -**/ios/Flutter/Flutter.framework -**/ios/Flutter/Generated.xcconfig -**/ios/Flutter/app.flx -**/ios/Flutter/app.zip -**/ios/Flutter/flutter_assets/ -**/ios/ServiceDefinitions.json -**/ios/Runner/GeneratedPluginRegistrant.* +# Obfuscation related +app.*.map.json -# Exceptions to above rules. -!**/ios/**/default.mode1v3 -!**/ios/**/default.mode2v3 -!**/ios/**/default.pbxuser -!**/ios/**/default.perspectivev3 -!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages -example/.flutter-plugins-dependencies +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release diff --git a/flutter_cache_manager/example/lib/generated_plugin_registrant.dart b/flutter_cache_manager/example/lib/generated_plugin_registrant.dart deleted file mode 100644 index 438d9d41..00000000 --- a/flutter_cache_manager/example/lib/generated_plugin_registrant.dart +++ /dev/null @@ -1,16 +0,0 @@ -// -// Generated file. Do not edit. -// - -// ignore_for_file: directives_ordering -// ignore_for_file: lines_longer_than_80_chars - -import 'package:url_launcher_web/url_launcher_web.dart'; - -import 'package:flutter_web_plugins/flutter_web_plugins.dart'; - -// ignore: public_member_api_docs -void registerPlugins(Registrar registrar) { - UrlLauncherPlugin.registerWith(registrar); - registrar.registerMessageHandler(); -} diff --git a/flutter_cache_manager/example/lib/main.dart b/flutter_cache_manager/example/lib/main.dart index 05a7c185..dba68f8c 100644 --- a/flutter_cache_manager/example/lib/main.dart +++ b/flutter_cache_manager/example/lib/main.dart @@ -18,7 +18,7 @@ const url = 'https://blurha.sh/assets/images/img1.jpg'; /// Example [Widget] showing the functionalities of flutter_cache_manager class CacheManagerPage extends StatefulWidget { - const CacheManagerPage({Key key}) : super(key: key); + const CacheManagerPage({Key? key}) : super(key: key); static ExamplePage createPage() { return ExamplePage(Icons.save_alt, (context) => const CacheManagerPage()); @@ -29,7 +29,7 @@ class CacheManagerPage extends StatefulWidget { } class _CacheManagerPageState extends State { - Stream fileStream; + Stream? fileStream; void _downloadFile() { setState(() { @@ -50,7 +50,7 @@ class _CacheManagerPageState extends State { ); } return DownloadPage( - fileStream: fileStream, + fileStream: fileStream!, downloadFile: _downloadFile, clearCache: _clearCache, removeFile: _removeFile, diff --git a/flutter_cache_manager/example/lib/plugin_example/download_page.dart b/flutter_cache_manager/example/lib/plugin_example/download_page.dart index 44d4b979..8811e831 100644 --- a/flutter_cache_manager/example/lib/plugin_example/download_page.dart +++ b/flutter_cache_manager/example/lib/plugin_example/download_page.dart @@ -8,13 +8,13 @@ import 'progress_indicator.dart' as p_i; /// A [Widget] showing the information about the status of the [FileResponse] class DownloadPage extends StatelessWidget { final Stream fileStream; - final VoidCallback downloadFile; - final VoidCallback clearCache; - final VoidCallback removeFile; + final VoidCallback? downloadFile; + final VoidCallback? clearCache; + final VoidCallback? removeFile; const DownloadPage({ - Key key, - this.fileStream, + Key? key, + required this.fileStream, this.downloadFile, this.clearCache, this.removeFile, diff --git a/flutter_cache_manager/example/lib/plugin_example/file_info_widget.dart b/flutter_cache_manager/example/lib/plugin_example/file_info_widget.dart index bb39e1c7..98159e07 100644 --- a/flutter_cache_manager/example/lib/plugin_example/file_info_widget.dart +++ b/flutter_cache_manager/example/lib/plugin_example/file_info_widget.dart @@ -4,12 +4,12 @@ import 'package:flutter_cache_manager/flutter_cache_manager.dart'; /// A [Widget] showing all available information about the downloaded file class FileInfoWidget extends StatelessWidget { final FileInfo fileInfo; - final VoidCallback clearCache; - final VoidCallback removeFile; + final VoidCallback? clearCache; + final VoidCallback? removeFile; const FileInfoWidget({ - Key key, - this.fileInfo, + Key? key, + required this.fileInfo, this.clearCache, this.removeFile, }) : super(key: key); @@ -38,7 +38,7 @@ class FileInfoWidget extends StatelessWidget { Padding( padding: const EdgeInsets.all(10.0), // ignore: deprecated_member_use - child: RaisedButton( + child: ElevatedButton( child: const Text('CLEAR CACHE'), onPressed: clearCache, ), @@ -46,7 +46,7 @@ class FileInfoWidget extends StatelessWidget { Padding( padding: const EdgeInsets.all(10.0), // ignore: deprecated_member_use - child: RaisedButton( + child: ElevatedButton( child: const Text('REMOVE FILE'), onPressed: removeFile, ), diff --git a/flutter_cache_manager/example/lib/plugin_example/floating_action_button.dart b/flutter_cache_manager/example/lib/plugin_example/floating_action_button.dart index 890e5ec6..6a8f29ab 100644 --- a/flutter_cache_manager/example/lib/plugin_example/floating_action_button.dart +++ b/flutter_cache_manager/example/lib/plugin_example/floating_action_button.dart @@ -2,8 +2,9 @@ import 'package:flutter/material.dart'; /// A [FloatingActionButton] used for downloading a file in [CacheManagerPage] class Fab extends StatelessWidget { - final VoidCallback downloadFile; - const Fab({Key key, this.downloadFile}) : super(key: key); + final VoidCallback? downloadFile; + + const Fab({Key? key, this.downloadFile}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/flutter_cache_manager/example/lib/plugin_example/progress_indicator.dart b/flutter_cache_manager/example/lib/plugin_example/progress_indicator.dart index bc0acd4b..af2925ec 100644 --- a/flutter_cache_manager/example/lib/plugin_example/progress_indicator.dart +++ b/flutter_cache_manager/example/lib/plugin_example/progress_indicator.dart @@ -4,9 +4,9 @@ import 'package:flutter_cache_manager/flutter_cache_manager.dart'; /// A centered and sized [CircularProgressIndicator] to show download progress /// in the [DownloadPage]. class ProgressIndicator extends StatelessWidget { - final DownloadProgress progress; + final DownloadProgress? progress; - const ProgressIndicator({Key key, this.progress}) : super(key: key); + const ProgressIndicator({Key? key, this.progress}) : super(key: key); @override Widget build(BuildContext context) { diff --git a/flutter_cache_manager/example/linux/flutter/generated_plugins.cmake b/flutter_cache_manager/example/linux/flutter/generated_plugins.cmake index 1fc8ed34..f16b4c34 100644 --- a/flutter_cache_manager/example/linux/flutter/generated_plugins.cmake +++ b/flutter_cache_manager/example/linux/flutter/generated_plugins.cmake @@ -6,6 +6,9 @@ list(APPEND FLUTTER_PLUGIN_LIST url_launcher_linux ) +list(APPEND FLUTTER_FFI_PLUGIN_LIST +) + set(PLUGIN_BUNDLED_LIBRARIES) foreach(plugin ${FLUTTER_PLUGIN_LIST}) @@ -14,3 +17,8 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST}) list(APPEND PLUGIN_BUNDLED_LIBRARIES $) list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/linux plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/flutter_cache_manager/example/macos/Flutter/GeneratedPluginRegistrant.swift b/flutter_cache_manager/example/macos/Flutter/GeneratedPluginRegistrant.swift index 63307a96..d24127f3 100644 --- a/flutter_cache_manager/example/macos/Flutter/GeneratedPluginRegistrant.swift +++ b/flutter_cache_manager/example/macos/Flutter/GeneratedPluginRegistrant.swift @@ -5,7 +5,7 @@ import FlutterMacOS import Foundation -import path_provider_macos +import path_provider_foundation import sqflite import url_launcher_macos diff --git a/flutter_cache_manager/example/pubspec.yaml b/flutter_cache_manager/example/pubspec.yaml index 8c9a61dc..3df70b3e 100644 --- a/flutter_cache_manager/example/pubspec.yaml +++ b/flutter_cache_manager/example/pubspec.yaml @@ -5,24 +5,24 @@ publish_to: none version: 1.0.0+1 environment: - sdk: ">=2.10.2 <3.0.0" + sdk: ">=3.0.0 <4.0.0" dependencies: baseflow_plugin_template: git: url: https://github.com/Baseflow/baseflow_plugin_template.git - ref: v1.0.0 - cupertino_icons: ^1.0.2 + ref: v2.1.0 + cupertino_icons: ^1.0.5 flutter: sdk: flutter flutter_cache_manager: path: ../ - url_launcher: ^5.4.11 + url_launcher: ^6.1.11 dev_dependencies: flutter_test: sdk: flutter - flutter_lints: ^1.0.4 + flutter_lints: ^2.0.1 # The following section is specific to Flutter. diff --git a/flutter_cache_manager/example/windows/flutter/generated_plugin_registrant.cc b/flutter_cache_manager/example/windows/flutter/generated_plugin_registrant.cc index d9fdd539..4f788487 100644 --- a/flutter_cache_manager/example/windows/flutter/generated_plugin_registrant.cc +++ b/flutter_cache_manager/example/windows/flutter/generated_plugin_registrant.cc @@ -6,9 +6,9 @@ #include "generated_plugin_registrant.h" -#include +#include void RegisterPlugins(flutter::PluginRegistry* registry) { - UrlLauncherPluginRegisterWithRegistrar( - registry->GetRegistrarForPlugin("UrlLauncherPlugin")); + UrlLauncherWindowsRegisterWithRegistrar( + registry->GetRegistrarForPlugin("UrlLauncherWindows")); } diff --git a/flutter_cache_manager/example/windows/flutter/generated_plugins.cmake b/flutter_cache_manager/example/windows/flutter/generated_plugins.cmake index 411af46d..88b22e5c 100644 --- a/flutter_cache_manager/example/windows/flutter/generated_plugins.cmake +++ b/flutter_cache_manager/example/windows/flutter/generated_plugins.cmake @@ -6,6 +6,9 @@ list(APPEND FLUTTER_PLUGIN_LIST url_launcher_windows ) +list(APPEND FLUTTER_FFI_PLUGIN_LIST +) + set(PLUGIN_BUNDLED_LIBRARIES) foreach(plugin ${FLUTTER_PLUGIN_LIST}) @@ -14,3 +17,8 @@ foreach(plugin ${FLUTTER_PLUGIN_LIST}) list(APPEND PLUGIN_BUNDLED_LIBRARIES $) list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${plugin}_bundled_libraries}) endforeach(plugin) + +foreach(ffi_plugin ${FLUTTER_FFI_PLUGIN_LIST}) + add_subdirectory(flutter/ephemeral/.plugin_symlinks/${ffi_plugin}/windows plugins/${ffi_plugin}) + list(APPEND PLUGIN_BUNDLED_LIBRARIES ${${ffi_plugin}_bundled_libraries}) +endforeach(ffi_plugin) diff --git a/flutter_cache_manager/pubspec.yaml b/flutter_cache_manager/pubspec.yaml index 124d2745..17afdb9d 100644 --- a/flutter_cache_manager/pubspec.yaml +++ b/flutter_cache_manager/pubspec.yaml @@ -1,27 +1,27 @@ name: flutter_cache_manager description: Generic cache manager for flutter. Saves web files on the storages of the device and saves the cache info using sqflite. -version: 3.3.0 +version: 3.4.0 homepage: https://github.com/Baseflow/flutter_cache_manager/tree/master/flutter_cache_manager environment: - sdk: ">=2.12.0 <3.0.0" + sdk: '>=3.0.0 <4.0.0' dependencies: clock: ^1.1.0 - collection: ^1.15.0 - file: ">=6.0.0 <7.0.0" + collection: ^1.17.0 + file: '>=6.0.0 <8.0.0' flutter: sdk: flutter - http: ^0.13.0 + http: ^1.0.0 path: ^1.8.0 path_provider: ^2.0.0 - rxdart: ">=0.26.0 <0.28.0" - sqflite: ^2.0.0+3 + rxdart: '>=0.26.0 <0.28.0' + sqflite: ^2.2.0 uuid: ^3.0.0 dev_dependencies: - build_runner: ^1.11.5 + build_runner: ^2.3.0 flutter_test: sdk: flutter mockito: ^5.0.0 - flutter_lints: ^1.0.4 + flutter_lints: ^2.0.1 From 18e731d90f28badcd5cd67f0d9d23aa613ef2358 Mon Sep 17 00:00:00 2001 From: Carapacik Date: Wed, 24 May 2023 10:34:07 +0300 Subject: [PATCH 02/27] Update build_runner and mockito to support latest version --- flutter_cache_manager/pubspec.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flutter_cache_manager/pubspec.yaml b/flutter_cache_manager/pubspec.yaml index 17afdb9d..e4805c02 100644 --- a/flutter_cache_manager/pubspec.yaml +++ b/flutter_cache_manager/pubspec.yaml @@ -20,8 +20,8 @@ dependencies: uuid: ^3.0.0 dev_dependencies: - build_runner: ^2.3.0 + build_runner: ^2.4.0 flutter_test: sdk: flutter - mockito: ^5.0.0 + mockito: ^5.4.1 flutter_lints: ^2.0.1 From 3c173443b697953409a48ac2415799bfb271b2cb Mon Sep 17 00:00:00 2001 From: Carapacik Date: Mon, 29 May 2023 15:06:57 +0300 Subject: [PATCH 03/27] Add changelog --- flutter_cache_manager/CHANGELOG.md | 3 +++ flutter_cache_manager/lib/src/cache_manager.dart | 2 +- flutter_cache_manager/lib/src/cache_store.dart | 3 +-- .../cache_info_repositories/cache_object_provider.dart | 5 +++-- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/flutter_cache_manager/CHANGELOG.md b/flutter_cache_manager/CHANGELOG.md index f6b26e89..b55b17cf 100644 --- a/flutter_cache_manager/CHANGELOG.md +++ b/flutter_cache_manager/CHANGELOG.md @@ -1,3 +1,6 @@ +## [3.4.0] - 2023-05-29 +* Require Dart ^3.0.0 (for http ^1.0.0) + ## [3.3.0] - 2021-11-29 * Added option to manage the log level. Doesn't print failed downloads by default anymore. You can set it like this: ```dart diff --git a/flutter_cache_manager/lib/src/cache_manager.dart b/flutter_cache_manager/lib/src/cache_manager.dart index 6d85e40d..710d2cc9 100644 --- a/flutter_cache_manager/lib/src/cache_manager.dart +++ b/flutter_cache_manager/lib/src/cache_manager.dart @@ -2,7 +2,7 @@ import 'dart:async'; import 'dart:typed_data'; import 'package:file/file.dart'; -import 'package:flutter/foundation.dart'; +import 'package:flutter/foundation.dart' show visibleForTesting; import 'package:flutter_cache_manager/flutter_cache_manager.dart'; import 'package:flutter_cache_manager/src/cache_store.dart'; import 'package:flutter_cache_manager/src/storage/cache_object.dart'; diff --git a/flutter_cache_manager/lib/src/cache_store.dart b/flutter_cache_manager/lib/src/cache_store.dart index 295b516e..fa7f999e 100644 --- a/flutter_cache_manager/lib/src/cache_store.dart +++ b/flutter_cache_manager/lib/src/cache_store.dart @@ -1,8 +1,7 @@ import 'dart:async'; -import 'package:flutter_cache_manager/src/storage/file_system/file_system.dart'; - import '../flutter_cache_manager.dart'; +import '../src/storage/file_system/file_system.dart'; import 'storage/cache_object.dart'; ///Flutter Cache Manager diff --git a/flutter_cache_manager/lib/src/storage/cache_info_repositories/cache_object_provider.dart b/flutter_cache_manager/lib/src/storage/cache_info_repositories/cache_object_provider.dart index 8e3b92a6..c8ba5a66 100644 --- a/flutter_cache_manager/lib/src/storage/cache_info_repositories/cache_object_provider.dart +++ b/flutter_cache_manager/lib/src/storage/cache_info_repositories/cache_object_provider.dart @@ -1,11 +1,12 @@ import 'dart:io'; -import 'package:flutter_cache_manager/src/storage/cache_info_repositories/helper_methods.dart'; import 'package:path/path.dart'; import 'package:path_provider/path_provider.dart'; import 'package:sqflite/sqflite.dart'; + import '../cache_object.dart'; import 'cache_info_repository.dart'; +import 'helper_methods.dart'; const _tableCacheObject = 'cacheObject'; @@ -124,7 +125,7 @@ class CacheObjectProvider extends CacheInfoRepository @override Future deleteAll(Iterable ids) { return db!.delete(_tableCacheObject, - where: '${CacheObject.columnId} IN (' + ids.join(',') + ')'); + where: '${CacheObject.columnId} IN (${ids.join(',')})'); } @override From 8cf0557639613c0cc4c915a5d3cc10c738b54c04 Mon Sep 17 00:00:00 2001 From: Carapacik Date: Fri, 2 Jun 2023 16:09:47 +0300 Subject: [PATCH 04/27] Format code --- .../lib/src/cache_managers/default_cache_manager.dart | 1 + flutter_cache_manager/lib/src/cache_store.dart | 3 +++ .../lib/src/compat/file_service_compat.dart | 1 + flutter_cache_manager/lib/src/config/config.dart | 5 +++++ flutter_cache_manager/lib/src/web/file_service.dart | 3 +++ flutter_cache_manager/lib/src/web/web_helper.dart | 1 + flutter_cache_manager/pubspec.yaml | 4 ++-- flutter_cache_manager/test/http_file_fetcher_test.dart | 4 ++-- flutter_cache_manager/test/image_cache_manager_test.dart | 4 ++-- 9 files changed, 20 insertions(+), 6 deletions(-) diff --git a/flutter_cache_manager/lib/src/cache_managers/default_cache_manager.dart b/flutter_cache_manager/lib/src/cache_managers/default_cache_manager.dart index 17e34e63..c390e34c 100644 --- a/flutter_cache_manager/lib/src/cache_managers/default_cache_manager.dart +++ b/flutter_cache_manager/lib/src/cache_managers/default_cache_manager.dart @@ -7,6 +7,7 @@ class DefaultCacheManager extends CacheManager with ImageCacheManager { static const key = 'libCachedImageData'; static final DefaultCacheManager _instance = DefaultCacheManager._(); + factory DefaultCacheManager() { return _instance; } diff --git a/flutter_cache_manager/lib/src/cache_store.dart b/flutter_cache_manager/lib/src/cache_store.dart index fa7f999e..77e9f5de 100644 --- a/flutter_cache_manager/lib/src/cache_store.dart +++ b/flutter_cache_manager/lib/src/cache_store.dart @@ -17,9 +17,12 @@ class CacheStore { FileSystem fileSystem; final Config _config; + String get storeKey => _config.cacheKey; final Future _cacheInfoRepository; + int get _capacity => _config.maxNrOfCacheObjects; + Duration get _maxAge => _config.stalePeriod; DateTime lastCleanupRun = DateTime.now(); diff --git a/flutter_cache_manager/lib/src/compat/file_service_compat.dart b/flutter_cache_manager/lib/src/compat/file_service_compat.dart index 874da63f..1a2c5d63 100644 --- a/flutter_cache_manager/lib/src/compat/file_service_compat.dart +++ b/flutter_cache_manager/lib/src/compat/file_service_compat.dart @@ -7,6 +7,7 @@ import '../web/mime_converter.dart'; class FileServiceCompat extends FileService { final FileFetcher fileFetcher; + FileServiceCompat(this.fileFetcher); @override diff --git a/flutter_cache_manager/lib/src/config/config.dart b/flutter_cache_manager/lib/src/config/config.dart index 655ead43..7fa42922 100644 --- a/flutter_cache_manager/lib/src/config/config.dart +++ b/flutter_cache_manager/lib/src/config/config.dart @@ -32,9 +32,14 @@ abstract class Config { }) = impl.Config; String get cacheKey; + Duration get stalePeriod; + int get maxNrOfCacheObjects; + CacheInfoRepository get repo; + FileSystem get fileSystem; + FileService get fileService; } diff --git a/flutter_cache_manager/lib/src/web/file_service.dart b/flutter_cache_manager/lib/src/web/file_service.dart index d72330eb..24f68a47 100644 --- a/flutter_cache_manager/lib/src/web/file_service.dart +++ b/flutter_cache_manager/lib/src/web/file_service.dart @@ -1,7 +1,9 @@ import 'dart:async'; import 'dart:io'; + import 'package:clock/clock.dart'; import 'package:http/http.dart' as http; + import 'mime_converter.dart'; ///Flutter Cache Manager @@ -14,6 +16,7 @@ import 'mime_converter.dart'; /// from other apps or from local storage. abstract class FileService { int concurrentFetches = 10; + Future get(String url, {Map? headers}); } diff --git a/flutter_cache_manager/lib/src/web/web_helper.dart b/flutter_cache_manager/lib/src/web/web_helper.dart index e7e0ef37..cbe3d623 100644 --- a/flutter_cache_manager/lib/src/web/web_helper.dart +++ b/flutter_cache_manager/lib/src/web/web_helper.dart @@ -45,6 +45,7 @@ class WebHelper { } var concurrentCalls = 0; + Future _downloadOrAddToQueue( String url, String key, diff --git a/flutter_cache_manager/pubspec.yaml b/flutter_cache_manager/pubspec.yaml index e4805c02..8e26354c 100644 --- a/flutter_cache_manager/pubspec.yaml +++ b/flutter_cache_manager/pubspec.yaml @@ -7,7 +7,7 @@ environment: sdk: '>=3.0.0 <4.0.0' dependencies: - clock: ^1.1.0 + clock: ^1.1.1 collection: ^1.17.0 file: '>=6.0.0 <8.0.0' flutter: @@ -15,7 +15,7 @@ dependencies: http: ^1.0.0 path: ^1.8.0 path_provider: ^2.0.0 - rxdart: '>=0.26.0 <0.28.0' + rxdart: ^0.27.0 sqflite: ^2.2.0 uuid: ^3.0.0 diff --git a/flutter_cache_manager/test/http_file_fetcher_test.dart b/flutter_cache_manager/test/http_file_fetcher_test.dart index 3cc7462d..4cdc6d27 100644 --- a/flutter_cache_manager/test/http_file_fetcher_test.dart +++ b/flutter_cache_manager/test/http_file_fetcher_test.dart @@ -82,14 +82,14 @@ void main() { }); }); - Future _defaultHttpGetter(String url, + Future defaultHttpGetter(String url, {Map? headers}) async { var httpResponse = await client.get(Uri.parse(url), headers: headers); return HttpFileFetcherResponse(httpResponse); } await withClock(Clock.fixed(DateTime.now()), () async { - var httpFileFetcher = FileServiceCompat(_defaultHttpGetter); + var httpFileFetcher = FileServiceCompat(defaultHttpGetter); final now = clock.now(); final response = await httpFileFetcher.get('http://test.com/image'); diff --git a/flutter_cache_manager/test/image_cache_manager_test.dart b/flutter_cache_manager/test/image_cache_manager_test.dart index 5e6b57e4..d2a43ef5 100644 --- a/flutter_cache_manager/test/image_cache_manager_test.dart +++ b/flutter_cache_manager/test/image_cache_manager_test.dart @@ -17,8 +17,8 @@ void main() { setUp(WidgetsFlutterBinding.ensureInitialized); tearDown(() { - PaintingBinding.instance?.imageCache?.clear(); - PaintingBinding.instance?.imageCache?.clearLiveImages(); + PaintingBinding.instance.imageCache.clear(); + PaintingBinding.instance.imageCache.clearLiveImages(); }); group('Test image resizing', () { From d1dbbe6ec598c553152977e4a9bad82f680f077e Mon Sep 17 00:00:00 2001 From: Carapacik Date: Fri, 2 Jun 2023 16:31:45 +0300 Subject: [PATCH 05/27] Update path_provider to support newest xdg_directories --- flutter_cache_manager/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flutter_cache_manager/pubspec.yaml b/flutter_cache_manager/pubspec.yaml index 8e26354c..18ba71a9 100644 --- a/flutter_cache_manager/pubspec.yaml +++ b/flutter_cache_manager/pubspec.yaml @@ -14,7 +14,7 @@ dependencies: sdk: flutter http: ^1.0.0 path: ^1.8.0 - path_provider: ^2.0.0 + path_provider: ^2.0.15 rxdart: ^0.27.0 sqflite: ^2.2.0 uuid: ^3.0.0 From dd0821ee0ff297f578783102373bed64d05bf178 Mon Sep 17 00:00:00 2001 From: Carapacik Date: Thu, 8 Jun 2023 11:31:28 +0300 Subject: [PATCH 06/27] Update example for latest baseflow_plugin_template --- flutter_cache_manager/example/lib/main.dart | 20 +++++++------- .../lib/plugin_example/download_page.dart | 12 ++++----- .../lib/plugin_example/file_info_widget.dart | 26 +++++++++---------- .../floating_action_button.dart | 2 +- .../plugin_example/progress_indicator.dart | 8 +++--- flutter_cache_manager/example/pubspec.yaml | 8 +----- 6 files changed, 36 insertions(+), 40 deletions(-) diff --git a/flutter_cache_manager/example/lib/main.dart b/flutter_cache_manager/example/lib/main.dart index dba68f8c..a7d61c72 100644 --- a/flutter_cache_manager/example/lib/main.dart +++ b/flutter_cache_manager/example/lib/main.dart @@ -5,12 +5,14 @@ import 'package:flutter/material.dart'; import 'package:flutter_cache_manager/flutter_cache_manager.dart'; void main() { - runApp(BaseflowPluginExample( - pluginName: 'Flutter Cache Manager', - githubURL: 'https://github.com/Baseflow/flutter_cache_manager', - pubDevURL: 'https://pub.dev/packages/flutter_cache_manager', - pages: [CacheManagerPage.createPage()], - )); + runApp( + BaseflowPluginExample( + pluginName: 'Flutter Cache Manager', + githubURL: 'https://github.com/Baseflow/flutter_cache_manager', + pubDevURL: 'https://pub.dev/packages/flutter_cache_manager', + pages: [CacheManagerPage.createPage()], + ), + ); CacheManager.logLevel = CacheManagerLogLevel.verbose; } @@ -18,7 +20,7 @@ const url = 'https://blurha.sh/assets/images/img1.jpg'; /// Example [Widget] showing the functionalities of flutter_cache_manager class CacheManagerPage extends StatefulWidget { - const CacheManagerPage({Key? key}) : super(key: key); + const CacheManagerPage({super.key}); static ExamplePage createPage() { return ExamplePage(Icons.save_alt, (context) => const CacheManagerPage()); @@ -41,9 +43,9 @@ class _CacheManagerPageState extends State { Widget build(BuildContext context) { if (fileStream == null) { return Scaffold( - appBar: null, body: const ListTile( - title: Text('Tap the floating action button to download.')), + title: Text('Tap the floating action button to download.'), + ), floatingActionButton: Fab( downloadFile: _downloadFile, ), diff --git a/flutter_cache_manager/example/lib/plugin_example/download_page.dart b/flutter_cache_manager/example/lib/plugin_example/download_page.dart index 8811e831..0b9dfc16 100644 --- a/flutter_cache_manager/example/lib/plugin_example/download_page.dart +++ b/flutter_cache_manager/example/lib/plugin_example/download_page.dart @@ -13,12 +13,12 @@ class DownloadPage extends StatelessWidget { final VoidCallback? removeFile; const DownloadPage({ - Key? key, + super.key, required this.fileStream, this.downloadFile, this.clearCache, this.removeFile, - }) : super(key: key); + }); @override Widget build(BuildContext context) { @@ -27,7 +27,7 @@ class DownloadPage extends StatelessWidget { builder: (context, snapshot) { Widget body; - var loading = !snapshot.hasData || snapshot.data is DownloadProgress; + final loading = !snapshot.hasData || snapshot.data is DownloadProgress; if (snapshot.hasError) { body = ListTile( @@ -36,17 +36,17 @@ class DownloadPage extends StatelessWidget { ); } else if (loading) { body = p_i.ProgressIndicator( - progress: snapshot.data as DownloadProgress); + progress: snapshot.data as DownloadProgress, + ); } else { body = FileInfoWidget( - fileInfo: snapshot.data as FileInfo, + fileInfo: snapshot.requireData as FileInfo, clearCache: clearCache, removeFile: removeFile, ); } return Scaffold( - appBar: null, body: body, floatingActionButton: !loading ? Fab( diff --git a/flutter_cache_manager/example/lib/plugin_example/file_info_widget.dart b/flutter_cache_manager/example/lib/plugin_example/file_info_widget.dart index 98159e07..56a7a3b6 100644 --- a/flutter_cache_manager/example/lib/plugin_example/file_info_widget.dart +++ b/flutter_cache_manager/example/lib/plugin_example/file_info_widget.dart @@ -3,16 +3,16 @@ import 'package:flutter_cache_manager/flutter_cache_manager.dart'; /// A [Widget] showing all available information about the downloaded file class FileInfoWidget extends StatelessWidget { - final FileInfo fileInfo; + final FileInfo? fileInfo; final VoidCallback? clearCache; final VoidCallback? removeFile; const FileInfoWidget({ - Key? key, - required this.fileInfo, + super.key, + this.fileInfo, this.clearCache, this.removeFile, - }) : super(key: key); + }); @override Widget build(BuildContext context) { @@ -20,35 +20,35 @@ class FileInfoWidget extends StatelessWidget { children: [ ListTile( title: const Text('Original URL'), - subtitle: Text(fileInfo.originalUrl), + subtitle: Text(fileInfo?.originalUrl ?? ''), ), - if (fileInfo.file != null) + if (fileInfo?.file != null) ListTile( title: const Text('Local file path'), - subtitle: Text(fileInfo.file.path), + subtitle: Text(fileInfo?.file.path ?? ''), ), ListTile( title: const Text('Loaded from'), - subtitle: Text(fileInfo.source.toString()), + subtitle: Text(fileInfo?.source.toString() ?? ''), ), ListTile( title: const Text('Valid Until'), - subtitle: Text(fileInfo.validTill.toIso8601String()), + subtitle: Text(fileInfo?.validTill.toIso8601String() ?? ''), ), Padding( - padding: const EdgeInsets.all(10.0), + padding: const EdgeInsets.all(10), // ignore: deprecated_member_use child: ElevatedButton( - child: const Text('CLEAR CACHE'), onPressed: clearCache, + child: const Text('CLEAR CACHE'), ), ), Padding( - padding: const EdgeInsets.all(10.0), + padding: const EdgeInsets.all(10), // ignore: deprecated_member_use child: ElevatedButton( - child: const Text('REMOVE FILE'), onPressed: removeFile, + child: const Text('REMOVE FILE'), ), ), ], diff --git a/flutter_cache_manager/example/lib/plugin_example/floating_action_button.dart b/flutter_cache_manager/example/lib/plugin_example/floating_action_button.dart index 6a8f29ab..5fbd2bca 100644 --- a/flutter_cache_manager/example/lib/plugin_example/floating_action_button.dart +++ b/flutter_cache_manager/example/lib/plugin_example/floating_action_button.dart @@ -4,7 +4,7 @@ import 'package:flutter/material.dart'; class Fab extends StatelessWidget { final VoidCallback? downloadFile; - const Fab({Key? key, this.downloadFile}) : super(key: key); + const Fab({super.key, this.downloadFile}); @override Widget build(BuildContext context) { diff --git a/flutter_cache_manager/example/lib/plugin_example/progress_indicator.dart b/flutter_cache_manager/example/lib/plugin_example/progress_indicator.dart index af2925ec..bc08567c 100644 --- a/flutter_cache_manager/example/lib/plugin_example/progress_indicator.dart +++ b/flutter_cache_manager/example/lib/plugin_example/progress_indicator.dart @@ -6,7 +6,7 @@ import 'package:flutter_cache_manager/flutter_cache_manager.dart'; class ProgressIndicator extends StatelessWidget { final DownloadProgress? progress; - const ProgressIndicator({Key? key, this.progress}) : super(key: key); + const ProgressIndicator({super.key, this.progress}); @override Widget build(BuildContext context) { @@ -15,13 +15,13 @@ class ProgressIndicator extends StatelessWidget { mainAxisAlignment: MainAxisAlignment.center, children: [ SizedBox( - width: 50.0, - height: 50.0, + width: 50, + height: 50, child: CircularProgressIndicator( value: progress?.progress, ), ), - const SizedBox(width: 20.0), + const SizedBox(width: 20), const Text('Downloading'), ], ), diff --git a/flutter_cache_manager/example/pubspec.yaml b/flutter_cache_manager/example/pubspec.yaml index 3df70b3e..a1393462 100644 --- a/flutter_cache_manager/example/pubspec.yaml +++ b/flutter_cache_manager/example/pubspec.yaml @@ -8,10 +8,7 @@ environment: sdk: ">=3.0.0 <4.0.0" dependencies: - baseflow_plugin_template: - git: - url: https://github.com/Baseflow/baseflow_plugin_template.git - ref: v2.1.0 + baseflow_plugin_template: ^2.1.2 cupertino_icons: ^1.0.5 flutter: sdk: flutter @@ -24,11 +21,8 @@ dev_dependencies: sdk: flutter flutter_lints: ^2.0.1 - -# The following section is specific to Flutter. flutter: uses-material-design: true - assets: - packages/baseflow_plugin_template/logo.png - packages/baseflow_plugin_template/poweredByBaseflow.png From 6819fbc57b9d0bb6b167912bb87c63ef6c5d9c53 Mon Sep 17 00:00:00 2001 From: Carapacik Date: Mon, 19 Jun 2023 22:31:44 +0300 Subject: [PATCH 07/27] http >=0.13.0 <2.0.0 --- flutter_cache_manager/pubspec.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/flutter_cache_manager/pubspec.yaml b/flutter_cache_manager/pubspec.yaml index 18ba71a9..549f33d1 100644 --- a/flutter_cache_manager/pubspec.yaml +++ b/flutter_cache_manager/pubspec.yaml @@ -12,7 +12,7 @@ dependencies: file: '>=6.0.0 <8.0.0' flutter: sdk: flutter - http: ^1.0.0 + http: '>=0.13.0 <2.0.0' path: ^1.8.0 path_provider: ^2.0.15 rxdart: ^0.27.0 @@ -23,5 +23,5 @@ dev_dependencies: build_runner: ^2.4.0 flutter_test: sdk: flutter - mockito: ^5.4.1 + mockito: ^5.4.0 flutter_lints: ^2.0.1 From 7cce7e2970863734aeb791050374c13335e35c89 Mon Sep 17 00:00:00 2001 From: Carapacik Date: Mon, 19 Jun 2023 22:33:42 +0300 Subject: [PATCH 08/27] rxdart dependency --- flutter_cache_manager/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flutter_cache_manager/pubspec.yaml b/flutter_cache_manager/pubspec.yaml index 549f33d1..5b029eaf 100644 --- a/flutter_cache_manager/pubspec.yaml +++ b/flutter_cache_manager/pubspec.yaml @@ -15,7 +15,7 @@ dependencies: http: '>=0.13.0 <2.0.0' path: ^1.8.0 path_provider: ^2.0.15 - rxdart: ^0.27.0 + rxdart: ^0.26.0 sqflite: ^2.2.0 uuid: ^3.0.0 From 2624abce5b6194d9507a727fef1db794aa448ccd Mon Sep 17 00:00:00 2001 From: Carapacik Date: Mon, 19 Jun 2023 22:42:46 +0300 Subject: [PATCH 09/27] Fix rxdart dependency --- flutter_cache_manager/pubspec.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/flutter_cache_manager/pubspec.yaml b/flutter_cache_manager/pubspec.yaml index 5b029eaf..468f124e 100644 --- a/flutter_cache_manager/pubspec.yaml +++ b/flutter_cache_manager/pubspec.yaml @@ -15,7 +15,7 @@ dependencies: http: '>=0.13.0 <2.0.0' path: ^1.8.0 path_provider: ^2.0.15 - rxdart: ^0.26.0 + rxdart: '>=0.26.0 <1.0.0' sqflite: ^2.2.0 uuid: ^3.0.0 From 9d97fd06b16072976b67b3827f42eb8fc856be64 Mon Sep 17 00:00:00 2001 From: Carapacik Date: Mon, 19 Jun 2023 22:55:42 +0300 Subject: [PATCH 10/27] Fix for PR --- flutter_cache_manager/CHANGELOG.md | 4 ++-- flutter_cache_manager/pubspec.yaml | 17 ++++++++--------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/flutter_cache_manager/CHANGELOG.md b/flutter_cache_manager/CHANGELOG.md index b55b17cf..e90edc05 100644 --- a/flutter_cache_manager/CHANGELOG.md +++ b/flutter_cache_manager/CHANGELOG.md @@ -1,5 +1,5 @@ -## [3.4.0] - 2023-05-29 -* Require Dart ^3.0.0 (for http ^1.0.0) +## [3.3.1] - 2023-06-20 +* Support for Dart 3.0.0 and http ^1.0.0 ## [3.3.0] - 2021-11-29 * Added option to manage the log level. Doesn't print failed downloads by default anymore. You can set it like this: diff --git a/flutter_cache_manager/pubspec.yaml b/flutter_cache_manager/pubspec.yaml index 468f124e..a85fb7d6 100644 --- a/flutter_cache_manager/pubspec.yaml +++ b/flutter_cache_manager/pubspec.yaml @@ -1,27 +1,26 @@ name: flutter_cache_manager description: Generic cache manager for flutter. Saves web files on the storages of the device and saves the cache info using sqflite. -version: 3.4.0 +version: 3.3.1 homepage: https://github.com/Baseflow/flutter_cache_manager/tree/master/flutter_cache_manager - environment: - sdk: '>=3.0.0 <4.0.0' + sdk: '>=2.12.0 <4.0.0' dependencies: clock: ^1.1.1 collection: ^1.17.0 - file: '>=6.0.0 <8.0.0' + file: '>=6.1.4 <8.0.0' flutter: sdk: flutter http: '>=0.13.0 <2.0.0' path: ^1.8.0 - path_provider: ^2.0.15 - rxdart: '>=0.26.0 <1.0.0' - sqflite: ^2.2.0 + path_provider: ^2.0.0 + rxdart: '>=0.26.0 <0.28.0' + sqflite: ^2.0.0+4 uuid: ^3.0.0 dev_dependencies: - build_runner: ^2.4.0 + build_runner: '>=1.11.5 <3.0.0' flutter_test: sdk: flutter - mockito: ^5.4.0 + mockito: ^5.0.0 flutter_lints: ^2.0.1 From 0d994b24858a32fee14a50afe078dffbe7bcce5f Mon Sep 17 00:00:00 2001 From: Carapacik Date: Mon, 19 Jun 2023 23:19:38 +0300 Subject: [PATCH 11/27] Remove unawaited to support dart 2.12 --- flutter_cache_manager/lib/src/cache_manager.dart | 6 +++--- flutter_cache_manager/lib/src/cache_store.dart | 12 ++++++------ flutter_cache_manager/lib/src/logger.dart | 2 +- .../cache_info_repository.dart | 2 +- flutter_cache_manager/lib/src/web/queue_item.dart | 2 +- flutter_cache_manager/lib/src/web/web_helper.dart | 12 ++++++------ 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/flutter_cache_manager/lib/src/cache_manager.dart b/flutter_cache_manager/lib/src/cache_manager.dart index 710d2cc9..656cb505 100644 --- a/flutter_cache_manager/lib/src/cache_manager.dart +++ b/flutter_cache_manager/lib/src/cache_manager.dart @@ -149,7 +149,7 @@ class CacheManager implements BaseCacheManager { } } } - unawaited(streamController.close()); + streamController.close(); } ///Download the file and add to cache @@ -213,7 +213,7 @@ class CacheManager implements BaseCacheManager { final file = await _config.fileSystem.createFile(cacheObject.relativePath); await file.writeAsBytes(fileBytes); - unawaited(_store.putFile(cacheObject)); + _store.putFile(cacheObject); return file; } @@ -255,7 +255,7 @@ class CacheManager implements BaseCacheManager { .map((event) => event) .pipe(sink); - unawaited(_store.putFile(cacheObject)); + _store.putFile(cacheObject); return file; } diff --git a/flutter_cache_manager/lib/src/cache_store.dart b/flutter_cache_manager/lib/src/cache_store.dart index 77e9f5de..0c03197e 100644 --- a/flutter_cache_manager/lib/src/cache_store.dart +++ b/flutter_cache_manager/lib/src/cache_store.dart @@ -70,7 +70,7 @@ class CacheStore { } if (!_futureCache.containsKey(key)) { final completer = Completer(); - unawaited(_getCacheDataFromDatabase(key).then((cacheObject) async { + _getCacheDataFromDatabase(key).then((cacheObject) async { if (cacheObject?.id != null && !await _fileExists(cacheObject)) { final provider = await _cacheInfoRepository; await provider.delete(cacheObject!.id!); @@ -84,7 +84,7 @@ class CacheStore { } completer.complete(cacheObject); _futureCache.remove(key); - })); + }); _futureCache[key] = completer.future; } return _futureCache[key]; @@ -112,7 +112,7 @@ class CacheStore { final provider = await _cacheInfoRepository; final data = await provider.get(key); if (await _fileExists(data)) { - unawaited(_updateCacheDataInDatabase(data!)); + _updateCacheDataInDatabase(data!); } _scheduleCleanup(); return data; @@ -139,12 +139,12 @@ class CacheStore { final overCapacity = await provider.getObjectsOverCapacity(_capacity); for (final cacheObject in overCapacity) { - unawaited(_removeCachedFile(cacheObject, toRemove)); + _removeCachedFile(cacheObject, toRemove); } final oldObjects = await provider.getOldObjects(_maxAge); for (final cacheObject in oldObjects) { - unawaited(_removeCachedFile(cacheObject, toRemove)); + _removeCachedFile(cacheObject, toRemove); } await provider.deleteAll(toRemove); @@ -155,7 +155,7 @@ class CacheStore { final toRemove = []; final allObjects = await provider.getAllObjects(); for (final cacheObject in allObjects) { - unawaited(_removeCachedFile(cacheObject, toRemove)); + _removeCachedFile(cacheObject, toRemove); } await provider.deleteAll(toRemove); } diff --git a/flutter_cache_manager/lib/src/logger.dart b/flutter_cache_manager/lib/src/logger.dart index c5878f8d..9fa6a51a 100644 --- a/flutter_cache_manager/lib/src/logger.dart +++ b/flutter_cache_manager/lib/src/logger.dart @@ -14,7 +14,7 @@ enum CacheManagerLogLevel { /// [CacheLogger] which is used by the cache manager to log useful information class CacheLogger { - /// Function to log a message on a certain loglevel + /// Function to log a message on a certain log level void log(String message, CacheManagerLogLevel level) { if (CacheManager.logLevel.index >= level.index) { // ignore: avoid_print diff --git a/flutter_cache_manager/lib/src/storage/cache_info_repositories/cache_info_repository.dart b/flutter_cache_manager/lib/src/storage/cache_info_repositories/cache_info_repository.dart index 8a122503..bca299e8 100644 --- a/flutter_cache_manager/lib/src/storage/cache_info_repositories/cache_info_repository.dart +++ b/flutter_cache_manager/lib/src/storage/cache_info_repositories/cache_info_repository.dart @@ -43,7 +43,7 @@ abstract class CacheInfoRepository { Future> getOldObjects(Duration maxAge); /// Close the connection to the repository. If this is the last connection - /// to the repository it will return true and the repository is trully + /// to the repository it will return true and the repository is truly /// closed. If there are still open connections it will return false; Future close(); diff --git a/flutter_cache_manager/lib/src/web/queue_item.dart b/flutter_cache_manager/lib/src/web/queue_item.dart index 768d5811..ebfdea6b 100644 --- a/flutter_cache_manager/lib/src/web/queue_item.dart +++ b/flutter_cache_manager/lib/src/web/queue_item.dart @@ -3,5 +3,5 @@ class QueueItem { final String key; final Map? headers; - QueueItem(this.url, this.key, this.headers); + const QueueItem(this.url, this.key, this.headers); } diff --git a/flutter_cache_manager/lib/src/web/web_helper.dart b/flutter_cache_manager/lib/src/web/web_helper.dart index cbe3d623..6fe07e43 100644 --- a/flutter_cache_manager/lib/src/web/web_helper.dart +++ b/flutter_cache_manager/lib/src/web/web_helper.dart @@ -39,7 +39,7 @@ class WebHelper { if (subject == null || ignoreMemCache) { subject = BehaviorSubject(); _memCache[key] = subject; - unawaited(_downloadOrAddToQueue(url, key, authHeaders)); + _downloadOrAddToQueue(url, key, authHeaders); } return subject.stream; } @@ -139,11 +139,11 @@ class WebHelper { newCacheObject = newCacheObject.copyWith(length: savedBytes); } - unawaited(_store.putFile(newCacheObject).then((_) { + _store.putFile(newCacheObject).then((_) { if (newCacheObject.relativePath != oldCacheObject.relativePath) { _removeOldFile(oldCacheObject.relativePath); } - })); + }); final file = await _store.fileSystem.createFile( newCacheObject.relativePath, @@ -164,7 +164,7 @@ class WebHelper { if (!statusCodesFileNotChanged.contains(response.statusCode)) { if (!filePath.endsWith(fileExtension)) { //Delete old file directly when file extension changed - unawaited(_removeOldFile(filePath)); + _removeOldFile(filePath); } // Store new file on different path filePath = '${const Uuid().v1()}$fileExtension'; @@ -178,11 +178,11 @@ class WebHelper { Stream _saveFile(CacheObject cacheObject, FileServiceResponse response) { var receivedBytesResultController = StreamController(); - unawaited(_saveFileAndPostUpdates( + _saveFileAndPostUpdates( receivedBytesResultController, cacheObject, response, - )); + ); return receivedBytesResultController.stream; } From cdce65f4e1f69d3fa9bf417a17a702daaf49843b Mon Sep 17 00:00:00 2001 From: Carapacik Date: Mon, 19 Jun 2023 23:27:01 +0300 Subject: [PATCH 12/27] Fixes for analyzer --- flutter_cache_manager/analysis_options.yaml | 2 +- flutter_cache_manager/example/lib/main.dart | 4 +- .../cache_managers/base_cache_manager.dart | 5 +- .../cache_managers/default_cache_manager.dart | 2 +- .../lib/src/cache_store.dart | 6 +- .../lib/src/compat/file_service_compat.dart | 5 +- .../lib/src/config/_config_io.dart | 3 +- .../lib/src/config/_config_unsupported.dart | 3 +- .../lib/src/config/_config_web.dart | 3 +- .../lib/src/config/config.dart | 5 +- flutter_cache_manager/lib/src/logger.dart | 2 +- .../cache_object_provider.dart | 7 +- .../json_cache_info_repository.dart | 5 +- .../non_storing_object_provider.dart | 3 +- .../storage/file_system/file_system_io.dart | 3 +- .../lib/src/web/file_service.dart | 3 +- flutter_cache_manager/test/mock.mocks.dart | 572 ++++++++++++------ 17 files changed, 418 insertions(+), 215 deletions(-) diff --git a/flutter_cache_manager/analysis_options.yaml b/flutter_cache_manager/analysis_options.yaml index a3be6b82..f9b30346 100644 --- a/flutter_cache_manager/analysis_options.yaml +++ b/flutter_cache_manager/analysis_options.yaml @@ -1 +1 @@ -include: package:flutter_lints/flutter.yaml \ No newline at end of file +include: package:flutter_lints/flutter.yaml diff --git a/flutter_cache_manager/example/lib/main.dart b/flutter_cache_manager/example/lib/main.dart index a7d61c72..8ba69c4c 100644 --- a/flutter_cache_manager/example/lib/main.dart +++ b/flutter_cache_manager/example/lib/main.dart @@ -27,10 +27,10 @@ class CacheManagerPage extends StatefulWidget { } @override - _CacheManagerPageState createState() => _CacheManagerPageState(); + CacheManagerPageState createState() => CacheManagerPageState(); } -class _CacheManagerPageState extends State { +class CacheManagerPageState extends State { Stream? fileStream; void _downloadFile() { diff --git a/flutter_cache_manager/lib/src/cache_managers/base_cache_manager.dart b/flutter_cache_manager/lib/src/cache_managers/base_cache_manager.dart index 99206403..7449a1bc 100644 --- a/flutter_cache_manager/lib/src/cache_managers/base_cache_manager.dart +++ b/flutter_cache_manager/lib/src/cache_managers/base_cache_manager.dart @@ -1,9 +1,8 @@ import 'dart:typed_data'; import 'package:file/file.dart'; - -import '../result/file_info.dart'; -import '../result/file_response.dart'; +import 'package:flutter_cache_manager/src/result/file_info.dart'; +import 'package:flutter_cache_manager/src/result/file_response.dart'; /// Interface of the CacheManager. In general [CacheManager] can be used /// directly. diff --git a/flutter_cache_manager/lib/src/cache_managers/default_cache_manager.dart b/flutter_cache_manager/lib/src/cache_managers/default_cache_manager.dart index c390e34c..15d83c57 100644 --- a/flutter_cache_manager/lib/src/cache_managers/default_cache_manager.dart +++ b/flutter_cache_manager/lib/src/cache_managers/default_cache_manager.dart @@ -1,4 +1,4 @@ -import '../../flutter_cache_manager.dart'; +import 'package:flutter_cache_manager/flutter_cache_manager.dart'; /// The DefaultCacheManager that can be easily used directly. The code of /// this implementation can be used as inspiration for more complex cache diff --git a/flutter_cache_manager/lib/src/cache_store.dart b/flutter_cache_manager/lib/src/cache_store.dart index 0c03197e..c3d7fa06 100644 --- a/flutter_cache_manager/lib/src/cache_store.dart +++ b/flutter_cache_manager/lib/src/cache_store.dart @@ -1,8 +1,8 @@ import 'dart:async'; -import '../flutter_cache_manager.dart'; -import '../src/storage/file_system/file_system.dart'; -import 'storage/cache_object.dart'; +import 'package:flutter_cache_manager/flutter_cache_manager.dart'; +import 'package:flutter_cache_manager/src/storage/cache_object.dart'; +import 'package:flutter_cache_manager/src/storage/file_system/file_system.dart'; ///Flutter Cache Manager ///Copyright (c) 2019 Rene Floor diff --git a/flutter_cache_manager/lib/src/compat/file_service_compat.dart b/flutter_cache_manager/lib/src/compat/file_service_compat.dart index 1a2c5d63..5d22660d 100644 --- a/flutter_cache_manager/lib/src/compat/file_service_compat.dart +++ b/flutter_cache_manager/lib/src/compat/file_service_compat.dart @@ -1,9 +1,8 @@ import 'dart:io'; import 'package:clock/clock.dart'; - -import '../../flutter_cache_manager.dart'; -import '../web/mime_converter.dart'; +import 'package:flutter_cache_manager/flutter_cache_manager.dart'; +import 'package:flutter_cache_manager/src/web/mime_converter.dart'; class FileServiceCompat extends FileService { final FileFetcher fileFetcher; diff --git a/flutter_cache_manager/lib/src/config/_config_io.dart b/flutter_cache_manager/lib/src/config/_config_io.dart index 1084572f..9ff7eadf 100644 --- a/flutter_cache_manager/lib/src/config/_config_io.dart +++ b/flutter_cache_manager/lib/src/config/_config_io.dart @@ -1,11 +1,10 @@ import 'dart:io'; import 'package:flutter_cache_manager/flutter_cache_manager.dart'; +import 'package:flutter_cache_manager/src/config/config.dart' as def; import 'package:flutter_cache_manager/src/storage/file_system/file_system.dart'; import 'package:flutter_cache_manager/src/storage/file_system/file_system_io.dart'; -import 'config.dart' as def; - class Config implements def.Config { Config( this.cacheKey, { diff --git a/flutter_cache_manager/lib/src/config/_config_unsupported.dart b/flutter_cache_manager/lib/src/config/_config_unsupported.dart index 57386bc3..b14ebeb3 100644 --- a/flutter_cache_manager/lib/src/config/_config_unsupported.dart +++ b/flutter_cache_manager/lib/src/config/_config_unsupported.dart @@ -1,9 +1,8 @@ +import 'package:flutter_cache_manager/src/config/config.dart' as def; import 'package:flutter_cache_manager/src/storage/cache_info_repositories/cache_info_repository.dart'; import 'package:flutter_cache_manager/src/storage/file_system/file_system.dart'; import 'package:flutter_cache_manager/src/web/file_service.dart'; -import 'config.dart' as def; - class Config implements def.Config { //ignore: avoid_unused_constructor_parameters Config( diff --git a/flutter_cache_manager/lib/src/config/_config_web.dart b/flutter_cache_manager/lib/src/config/_config_web.dart index dce3622f..3b1e433c 100644 --- a/flutter_cache_manager/lib/src/config/_config_web.dart +++ b/flutter_cache_manager/lib/src/config/_config_web.dart @@ -1,11 +1,10 @@ +import 'package:flutter_cache_manager/src/config/config.dart' as def; import 'package:flutter_cache_manager/src/storage/cache_info_repositories/cache_info_repository.dart'; import 'package:flutter_cache_manager/src/storage/cache_info_repositories/non_storing_object_provider.dart'; import 'package:flutter_cache_manager/src/storage/file_system/file_system.dart'; import 'package:flutter_cache_manager/src/storage/file_system/file_system_web.dart'; import 'package:flutter_cache_manager/src/web/file_service.dart'; -import 'config.dart' as def; - class Config implements def.Config { Config( this.cacheKey, { diff --git a/flutter_cache_manager/lib/src/config/config.dart b/flutter_cache_manager/lib/src/config/config.dart index 7fa42922..a0dc4894 100644 --- a/flutter_cache_manager/lib/src/config/config.dart +++ b/flutter_cache_manager/lib/src/config/config.dart @@ -1,9 +1,8 @@ import 'package:flutter_cache_manager/flutter_cache_manager.dart'; -import 'package:flutter_cache_manager/src/storage/file_system/file_system.dart'; - -import '_config_unsupported.dart' +import 'package:flutter_cache_manager/src/config/_config_unsupported.dart' if (dart.library.html) '_config_web.dart' if (dart.library.io) '_config_io.dart' as impl; +import 'package:flutter_cache_manager/src/storage/file_system/file_system.dart'; abstract class Config { /// Config file for the CacheManager. diff --git a/flutter_cache_manager/lib/src/logger.dart b/flutter_cache_manager/lib/src/logger.dart index 9fa6a51a..75d08bec 100644 --- a/flutter_cache_manager/lib/src/logger.dart +++ b/flutter_cache_manager/lib/src/logger.dart @@ -1,4 +1,4 @@ -import '../flutter_cache_manager.dart'; +import 'package:flutter_cache_manager/flutter_cache_manager.dart'; /// Instance of the cache manager. Can be set to a custom one if preferred. CacheLogger cacheLogger = CacheLogger(); diff --git a/flutter_cache_manager/lib/src/storage/cache_info_repositories/cache_object_provider.dart b/flutter_cache_manager/lib/src/storage/cache_info_repositories/cache_object_provider.dart index c8ba5a66..3cd28250 100644 --- a/flutter_cache_manager/lib/src/storage/cache_info_repositories/cache_object_provider.dart +++ b/flutter_cache_manager/lib/src/storage/cache_info_repositories/cache_object_provider.dart @@ -1,13 +1,12 @@ import 'dart:io'; +import 'package:flutter_cache_manager/src/storage/cache_info_repositories/cache_info_repository.dart'; +import 'package:flutter_cache_manager/src/storage/cache_info_repositories/helper_methods.dart'; +import 'package:flutter_cache_manager/src/storage/cache_object.dart'; import 'package:path/path.dart'; import 'package:path_provider/path_provider.dart'; import 'package:sqflite/sqflite.dart'; -import '../cache_object.dart'; -import 'cache_info_repository.dart'; -import 'helper_methods.dart'; - const _tableCacheObject = 'cacheObject'; class CacheObjectProvider extends CacheInfoRepository diff --git a/flutter_cache_manager/lib/src/storage/cache_info_repositories/json_cache_info_repository.dart b/flutter_cache_manager/lib/src/storage/cache_info_repositories/json_cache_info_repository.dart index c4963662..97b153d8 100644 --- a/flutter_cache_manager/lib/src/storage/cache_info_repositories/json_cache_info_repository.dart +++ b/flutter_cache_manager/lib/src/storage/cache_info_repositories/json_cache_info_repository.dart @@ -5,13 +5,12 @@ import 'dart:math'; import 'package:collection/collection.dart'; import 'package:flutter/widgets.dart'; +import 'package:flutter_cache_manager/src/storage/cache_info_repositories/cache_info_repository.dart'; +import 'package:flutter_cache_manager/src/storage/cache_info_repositories/helper_methods.dart'; import 'package:flutter_cache_manager/src/storage/cache_object.dart'; import 'package:path/path.dart'; import 'package:path_provider/path_provider.dart'; -import 'cache_info_repository.dart'; -import 'helper_methods.dart'; - class JsonCacheInfoRepository extends CacheInfoRepository with CacheInfoRepositoryHelperMethods { Directory? directory; diff --git a/flutter_cache_manager/lib/src/storage/cache_info_repositories/non_storing_object_provider.dart b/flutter_cache_manager/lib/src/storage/cache_info_repositories/non_storing_object_provider.dart index a3646da7..4c2fa7b6 100644 --- a/flutter_cache_manager/lib/src/storage/cache_info_repositories/non_storing_object_provider.dart +++ b/flutter_cache_manager/lib/src/storage/cache_info_repositories/non_storing_object_provider.dart @@ -1,7 +1,6 @@ +import 'package:flutter_cache_manager/src/storage/cache_info_repositories/cache_info_repository.dart'; import 'package:flutter_cache_manager/src/storage/cache_object.dart'; -import 'cache_info_repository.dart'; - class NonStoringObjectProvider implements CacheInfoRepository { @override Future close() async { diff --git a/flutter_cache_manager/lib/src/storage/file_system/file_system_io.dart b/flutter_cache_manager/lib/src/storage/file_system/file_system_io.dart index 860045cd..0f75c4d5 100644 --- a/flutter_cache_manager/lib/src/storage/file_system/file_system_io.dart +++ b/flutter_cache_manager/lib/src/storage/file_system/file_system_io.dart @@ -1,10 +1,9 @@ import 'package:file/file.dart' hide FileSystem; import 'package:file/local.dart'; +import 'package:flutter_cache_manager/src/storage/file_system/file_system.dart'; import 'package:path/path.dart' as p; import 'package:path_provider/path_provider.dart'; -import 'file_system.dart'; - class IOFileSystem implements FileSystem { final Future _fileDir; final String _cacheKey; diff --git a/flutter_cache_manager/lib/src/web/file_service.dart b/flutter_cache_manager/lib/src/web/file_service.dart index 24f68a47..d8b90f44 100644 --- a/flutter_cache_manager/lib/src/web/file_service.dart +++ b/flutter_cache_manager/lib/src/web/file_service.dart @@ -2,10 +2,9 @@ import 'dart:async'; import 'dart:io'; import 'package:clock/clock.dart'; +import 'package:flutter_cache_manager/src/web/mime_converter.dart'; import 'package:http/http.dart' as http; -import 'mime_converter.dart'; - ///Flutter Cache Manager ///Copyright (c) 2019 Rene Floor ///Released under MIT License. diff --git a/flutter_cache_manager/test/mock.mocks.dart b/flutter_cache_manager/test/mock.mocks.dart index ea57f65e..65312d65 100644 --- a/flutter_cache_manager/test/mock.mocks.dart +++ b/flutter_cache_manager/test/mock.mocks.dart @@ -1,249 +1,463 @@ -// Mocks generated by Mockito 5.0.0-nullsafety.7 from annotations +// Mocks generated by Mockito 5.4.2 from annotations // in flutter_cache_manager/test/mock.dart. // Do not manually edit this file. -import 'dart:async' as _i7; +// ignore_for_file: no_leading_underscores_for_library_prefixes +import 'dart:async' as _i5; -import 'package:flutter_cache_manager/src/cache_store.dart' as _i8; -import 'package:flutter_cache_manager/src/result/file_info.dart' as _i4; -import 'package:flutter_cache_manager/src/result/file_response.dart' as _i10; -import 'package:flutter_cache_manager/src/storage/cache_info_repositories/cache_info_repository.dart' - as _i6; +import 'package:flutter_cache_manager/flutter_cache_manager.dart' as _i4; +import 'package:flutter_cache_manager/src/cache_store.dart' as _i6; import 'package:flutter_cache_manager/src/storage/cache_object.dart' as _i2; import 'package:flutter_cache_manager/src/storage/file_system/file_system.dart' as _i3; -import 'package:flutter_cache_manager/src/web/file_service.dart' as _i5; -import 'package:flutter_cache_manager/src/web/web_helper.dart' as _i9; +import 'package:flutter_cache_manager/src/web/web_helper.dart' as _i7; import 'package:mockito/mockito.dart' as _i1; +// ignore_for_file: type=lint +// ignore_for_file: avoid_redundant_argument_values +// ignore_for_file: avoid_setters_without_getters // ignore_for_file: comment_references +// ignore_for_file: implementation_imports +// ignore_for_file: invalid_use_of_visible_for_testing_member +// ignore_for_file: prefer_const_constructors // ignore_for_file: unnecessary_parenthesis +// ignore_for_file: camel_case_types +// ignore_for_file: subtype_of_sealed_class -class _FakeCacheObject extends _i1.Fake implements _i2.CacheObject {} - -class _FakeDuration extends _i1.Fake implements Duration {} +class _FakeCacheObject_0 extends _i1.SmartFake implements _i2.CacheObject { + _FakeCacheObject_0( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} -class _FakeFileSystem extends _i1.Fake implements _i3.FileSystem {} +class _FakeDuration_1 extends _i1.SmartFake implements Duration { + _FakeDuration_1( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} -class _FakeDateTime extends _i1.Fake implements DateTime {} +class _FakeFileSystem_2 extends _i1.SmartFake implements _i3.FileSystem { + _FakeFileSystem_2( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} -class _FakeFileInfo extends _i1.Fake implements _i4.FileInfo {} +class _FakeDateTime_3 extends _i1.SmartFake implements DateTime { + _FakeDateTime_3( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} -class _FakeFileServiceResponse extends _i1.Fake - implements _i5.FileServiceResponse {} +class _FakeFileServiceResponse_4 extends _i1.SmartFake + implements _i4.FileServiceResponse { + _FakeFileServiceResponse_4( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} -class _FakeFileService extends _i1.Fake implements _i5.FileService {} +class _FakeFileService_5 extends _i1.SmartFake implements _i4.FileService { + _FakeFileService_5( + Object parent, + Invocation parentInvocation, + ) : super( + parent, + parentInvocation, + ); +} /// A class which mocks [CacheInfoRepository]. /// /// See the documentation for Mockito's code generation for more information. class MockCacheInfoRepositoryBase extends _i1.Mock - implements _i6.CacheInfoRepository { + implements _i4.CacheInfoRepository { MockCacheInfoRepositoryBase() { _i1.throwOnMissingStub(this); } @override - _i7.Future exists() => - (super.noSuchMethod(Invocation.method(#exists, []), - returnValue: Future.value(false)) as _i7.Future); - @override - _i7.Future open() => (super.noSuchMethod(Invocation.method(#open, []), - returnValue: Future.value(false)) as _i7.Future); - @override - _i7.Future updateOrInsert(_i2.CacheObject? cacheObject) => - (super.noSuchMethod(Invocation.method(#updateOrInsert, [cacheObject]), - returnValue: Future.value(null)) as _i7.Future); - @override - _i7.Future<_i2.CacheObject> insert(_i2.CacheObject? cacheObject, - {bool? setTouchedToNow = true}) => + _i5.Future exists() => (super.noSuchMethod( + Invocation.method( + #exists, + [], + ), + returnValue: _i5.Future.value(false), + ) as _i5.Future); + @override + _i5.Future open() => (super.noSuchMethod( + Invocation.method( + #open, + [], + ), + returnValue: _i5.Future.value(false), + ) as _i5.Future); + @override + _i5.Future updateOrInsert(_i2.CacheObject? cacheObject) => (super.noSuchMethod( - Invocation.method( - #insert, [cacheObject], {#setTouchedToNow: setTouchedToNow}), - returnValue: Future.value(_FakeCacheObject())) - as _i7.Future<_i2.CacheObject>); - @override - _i7.Future<_i2.CacheObject?> get(String? key) => - (super.noSuchMethod(Invocation.method(#get, [key]), - returnValue: Future.value(_FakeCacheObject())) - as _i7.Future<_i2.CacheObject?>); - @override - _i7.Future delete(int? id) => - (super.noSuchMethod(Invocation.method(#delete, [id]), - returnValue: Future.value(0)) as _i7.Future); - @override - _i7.Future deleteAll(Iterable? ids) => - (super.noSuchMethod(Invocation.method(#deleteAll, [ids]), - returnValue: Future.value(0)) as _i7.Future); - @override - _i7.Future update(_i2.CacheObject? cacheObject, - {bool? setTouchedToNow = true}) => + Invocation.method( + #updateOrInsert, + [cacheObject], + ), + returnValue: _i5.Future.value(), + ) as _i5.Future); + @override + _i5.Future<_i2.CacheObject> insert( + _i2.CacheObject? cacheObject, { + bool? setTouchedToNow = true, + }) => (super.noSuchMethod( + Invocation.method( + #insert, + [cacheObject], + {#setTouchedToNow: setTouchedToNow}, + ), + returnValue: _i5.Future<_i2.CacheObject>.value(_FakeCacheObject_0( + this, Invocation.method( - #update, [cacheObject], {#setTouchedToNow: setTouchedToNow}), - returnValue: Future.value(0)) as _i7.Future); - @override - _i7.Future> getAllObjects() => - (super.noSuchMethod(Invocation.method(#getAllObjects, []), - returnValue: Future.value(<_i2.CacheObject>[])) - as _i7.Future>); - @override - _i7.Future> getObjectsOverCapacity(int? capacity) => + #insert, + [cacheObject], + {#setTouchedToNow: setTouchedToNow}, + ), + )), + ) as _i5.Future<_i2.CacheObject>); + @override + _i5.Future<_i2.CacheObject?> get(String? key) => (super.noSuchMethod( + Invocation.method( + #get, + [key], + ), + returnValue: _i5.Future<_i2.CacheObject?>.value(), + ) as _i5.Future<_i2.CacheObject?>); + @override + _i5.Future delete(int? id) => (super.noSuchMethod( + Invocation.method( + #delete, + [id], + ), + returnValue: _i5.Future.value(0), + ) as _i5.Future); + @override + _i5.Future deleteAll(Iterable? ids) => (super.noSuchMethod( + Invocation.method( + #deleteAll, + [ids], + ), + returnValue: _i5.Future.value(0), + ) as _i5.Future); + @override + _i5.Future update( + _i2.CacheObject? cacheObject, { + bool? setTouchedToNow = true, + }) => (super.noSuchMethod( - Invocation.method(#getObjectsOverCapacity, [capacity]), - returnValue: Future.value(<_i2.CacheObject>[])) - as _i7.Future>); - @override - _i7.Future> getOldObjects(Duration? maxAge) => - (super.noSuchMethod(Invocation.method(#getOldObjects, [maxAge]), - returnValue: Future.value(<_i2.CacheObject>[])) - as _i7.Future>); - @override - _i7.Future close() => (super.noSuchMethod(Invocation.method(#close, []), - returnValue: Future.value(false)) as _i7.Future); - @override - _i7.Future deleteDataFile() => - (super.noSuchMethod(Invocation.method(#deleteDataFile, []), - returnValue: Future.value(null), - returnValueForMissingStub: Future.value()) as _i7.Future); + Invocation.method( + #update, + [cacheObject], + {#setTouchedToNow: setTouchedToNow}, + ), + returnValue: _i5.Future.value(0), + ) as _i5.Future); + @override + _i5.Future> getAllObjects() => (super.noSuchMethod( + Invocation.method( + #getAllObjects, + [], + ), + returnValue: + _i5.Future>.value(<_i2.CacheObject>[]), + ) as _i5.Future>); + @override + _i5.Future> getObjectsOverCapacity(int? capacity) => + (super.noSuchMethod( + Invocation.method( + #getObjectsOverCapacity, + [capacity], + ), + returnValue: + _i5.Future>.value(<_i2.CacheObject>[]), + ) as _i5.Future>); + @override + _i5.Future> getOldObjects(Duration? maxAge) => + (super.noSuchMethod( + Invocation.method( + #getOldObjects, + [maxAge], + ), + returnValue: + _i5.Future>.value(<_i2.CacheObject>[]), + ) as _i5.Future>); + @override + _i5.Future close() => (super.noSuchMethod( + Invocation.method( + #close, + [], + ), + returnValue: _i5.Future.value(false), + ) as _i5.Future); + @override + _i5.Future deleteDataFile() => (super.noSuchMethod( + Invocation.method( + #deleteDataFile, + [], + ), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); } /// A class which mocks [CacheStore]. /// /// See the documentation for Mockito's code generation for more information. -class MockCacheStoreBase extends _i1.Mock implements _i8.CacheStore { +class MockCacheStoreBase extends _i1.Mock implements _i6.CacheStore { MockCacheStoreBase() { _i1.throwOnMissingStub(this); } @override - Duration get cleanupRunMinInterval => - (super.noSuchMethod(Invocation.getter(#cleanupRunMinInterval), - returnValue: _FakeDuration()) as Duration); + Duration get cleanupRunMinInterval => (super.noSuchMethod( + Invocation.getter(#cleanupRunMinInterval), + returnValue: _FakeDuration_1( + this, + Invocation.getter(#cleanupRunMinInterval), + ), + ) as Duration); @override set cleanupRunMinInterval(Duration? _cleanupRunMinInterval) => super.noSuchMethod( - Invocation.setter(#cleanupRunMinInterval, _cleanupRunMinInterval), - returnValueForMissingStub: null); - @override - _i3.FileSystem get fileSystem => - (super.noSuchMethod(Invocation.getter(#fileSystem), - returnValue: _FakeFileSystem()) as _i3.FileSystem); - @override - set fileSystem(_i3.FileSystem? _fileSystem) => - super.noSuchMethod(Invocation.setter(#fileSystem, _fileSystem), - returnValueForMissingStub: null); - @override - DateTime get lastCleanupRun => - (super.noSuchMethod(Invocation.getter(#lastCleanupRun), - returnValue: _FakeDateTime()) as DateTime); - @override - set lastCleanupRun(DateTime? _lastCleanupRun) => - super.noSuchMethod(Invocation.setter(#lastCleanupRun, _lastCleanupRun), - returnValueForMissingStub: null); - @override - String get storeKey => - (super.noSuchMethod(Invocation.getter(#storeKey), returnValue: '') - as String); - @override - _i7.Future<_i4.FileInfo?> getFile(String? key, - {bool? ignoreMemCache = false}) => + Invocation.setter( + #cleanupRunMinInterval, + _cleanupRunMinInterval, + ), + returnValueForMissingStub: null, + ); + @override + _i3.FileSystem get fileSystem => (super.noSuchMethod( + Invocation.getter(#fileSystem), + returnValue: _FakeFileSystem_2( + this, + Invocation.getter(#fileSystem), + ), + ) as _i3.FileSystem); + @override + set fileSystem(_i3.FileSystem? _fileSystem) => super.noSuchMethod( + Invocation.setter( + #fileSystem, + _fileSystem, + ), + returnValueForMissingStub: null, + ); + @override + DateTime get lastCleanupRun => (super.noSuchMethod( + Invocation.getter(#lastCleanupRun), + returnValue: _FakeDateTime_3( + this, + Invocation.getter(#lastCleanupRun), + ), + ) as DateTime); + @override + set lastCleanupRun(DateTime? _lastCleanupRun) => super.noSuchMethod( + Invocation.setter( + #lastCleanupRun, + _lastCleanupRun, + ), + returnValueForMissingStub: null, + ); + @override + String get storeKey => (super.noSuchMethod( + Invocation.getter(#storeKey), + returnValue: '', + ) as String); + @override + _i5.Future<_i4.FileInfo?> getFile( + String? key, { + bool? ignoreMemCache = false, + }) => (super.noSuchMethod( - Invocation.method(#getFile, [key], {#ignoreMemCache: ignoreMemCache}), - returnValue: - Future.value(_FakeFileInfo())) as _i7.Future<_i4.FileInfo?>); - @override - _i7.Future putFile(_i2.CacheObject? cacheObject) => - (super.noSuchMethod(Invocation.method(#putFile, [cacheObject]), - returnValue: Future.value(null), - returnValueForMissingStub: Future.value()) as _i7.Future); - @override - _i7.Future<_i2.CacheObject?> retrieveCacheData(String? key, - {bool? ignoreMemCache = false}) => + Invocation.method( + #getFile, + [key], + {#ignoreMemCache: ignoreMemCache}, + ), + returnValue: _i5.Future<_i4.FileInfo?>.value(), + ) as _i5.Future<_i4.FileInfo?>); + @override + _i5.Future putFile(_i2.CacheObject? cacheObject) => (super.noSuchMethod( + Invocation.method( + #putFile, + [cacheObject], + ), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); + @override + _i5.Future<_i2.CacheObject?> retrieveCacheData( + String? key, { + bool? ignoreMemCache = false, + }) => (super.noSuchMethod( - Invocation.method( - #retrieveCacheData, [key], {#ignoreMemCache: ignoreMemCache}), - returnValue: Future.value(_FakeCacheObject())) - as _i7.Future<_i2.CacheObject?>); - @override - _i7.Future<_i4.FileInfo?> getFileFromMemory(String? key) => - (super.noSuchMethod(Invocation.method(#getFileFromMemory, [key]), - returnValue: Future.value(_FakeFileInfo())) - as _i7.Future<_i4.FileInfo?>); - @override - _i7.Future emptyCache() => - (super.noSuchMethod(Invocation.method(#emptyCache, []), - returnValue: Future.value(null), - returnValueForMissingStub: Future.value()) as _i7.Future); - @override - _i7.Future removeCachedFile(_i2.CacheObject? cacheObject) => - (super.noSuchMethod(Invocation.method(#removeCachedFile, [cacheObject]), - returnValue: Future.value(null), - returnValueForMissingStub: Future.value()) as _i7.Future); - @override - _i7.Future dispose() => - (super.noSuchMethod(Invocation.method(#dispose, []), - returnValue: Future.value(null), - returnValueForMissingStub: Future.value()) as _i7.Future); + Invocation.method( + #retrieveCacheData, + [key], + {#ignoreMemCache: ignoreMemCache}, + ), + returnValue: _i5.Future<_i2.CacheObject?>.value(), + ) as _i5.Future<_i2.CacheObject?>); + @override + _i5.Future<_i4.FileInfo?> getFileFromMemory(String? key) => + (super.noSuchMethod( + Invocation.method( + #getFileFromMemory, + [key], + ), + returnValue: _i5.Future<_i4.FileInfo?>.value(), + ) as _i5.Future<_i4.FileInfo?>); + @override + _i5.Future emptyCache() => (super.noSuchMethod( + Invocation.method( + #emptyCache, + [], + ), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); + @override + void emptyMemoryCache() => super.noSuchMethod( + Invocation.method( + #emptyMemoryCache, + [], + ), + returnValueForMissingStub: null, + ); + @override + _i5.Future removeCachedFile(_i2.CacheObject? cacheObject) => + (super.noSuchMethod( + Invocation.method( + #removeCachedFile, + [cacheObject], + ), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); + @override + _i5.Future dispose() => (super.noSuchMethod( + Invocation.method( + #dispose, + [], + ), + returnValue: _i5.Future.value(), + returnValueForMissingStub: _i5.Future.value(), + ) as _i5.Future); } /// A class which mocks [FileService]. /// /// See the documentation for Mockito's code generation for more information. -class MockFileServiceBase extends _i1.Mock implements _i5.FileService { +class MockFileServiceBase extends _i1.Mock implements _i4.FileService { MockFileServiceBase() { _i1.throwOnMissingStub(this); } @override - int get concurrentFetches => - (super.noSuchMethod(Invocation.getter(#concurrentFetches), returnValue: 0) - as int); + int get concurrentFetches => (super.noSuchMethod( + Invocation.getter(#concurrentFetches), + returnValue: 0, + ) as int); @override set concurrentFetches(int? _concurrentFetches) => super.noSuchMethod( - Invocation.setter(#concurrentFetches, _concurrentFetches), - returnValueForMissingStub: null); - @override - _i7.Future<_i5.FileServiceResponse> get(String? url, - {Map? headers}) => - (super.noSuchMethod(Invocation.method(#get, [url], {#headers: headers}), - returnValue: Future.value(_FakeFileServiceResponse())) - as _i7.Future<_i5.FileServiceResponse>); + Invocation.setter( + #concurrentFetches, + _concurrentFetches, + ), + returnValueForMissingStub: null, + ); + @override + _i5.Future<_i4.FileServiceResponse> get( + String? url, { + Map? headers, + }) => + (super.noSuchMethod( + Invocation.method( + #get, + [url], + {#headers: headers}, + ), + returnValue: _i5.Future<_i4.FileServiceResponse>.value( + _FakeFileServiceResponse_4( + this, + Invocation.method( + #get, + [url], + {#headers: headers}, + ), + )), + ) as _i5.Future<_i4.FileServiceResponse>); } /// A class which mocks [WebHelper]. /// /// See the documentation for Mockito's code generation for more information. -class MockWebHelper extends _i1.Mock implements _i9.WebHelper { +class MockWebHelper extends _i1.Mock implements _i7.WebHelper { MockWebHelper() { _i1.throwOnMissingStub(this); } @override - _i5.FileService get fileFetcher => - (super.noSuchMethod(Invocation.getter(#fileFetcher), - returnValue: _FakeFileService()) as _i5.FileService); - @override - int get concurrentCalls => - (super.noSuchMethod(Invocation.getter(#concurrentCalls), returnValue: 0) - as int); - @override - set concurrentCalls(int? _concurrentCalls) => - super.noSuchMethod(Invocation.setter(#concurrentCalls, _concurrentCalls), - returnValueForMissingStub: null); - @override - _i7.Stream<_i10.FileResponse> downloadFile(String? url, - {String? key, - Map? authHeaders, - bool? ignoreMemCache = false}) => + _i4.FileService get fileFetcher => (super.noSuchMethod( + Invocation.getter(#fileFetcher), + returnValue: _FakeFileService_5( + this, + Invocation.getter(#fileFetcher), + ), + ) as _i4.FileService); + @override + int get concurrentCalls => (super.noSuchMethod( + Invocation.getter(#concurrentCalls), + returnValue: 0, + ) as int); + @override + set concurrentCalls(int? _concurrentCalls) => super.noSuchMethod( + Invocation.setter( + #concurrentCalls, + _concurrentCalls, + ), + returnValueForMissingStub: null, + ); + @override + _i5.Stream<_i4.FileResponse> downloadFile( + String? url, { + String? key, + Map? authHeaders, + bool? ignoreMemCache = false, + }) => (super.noSuchMethod( - Invocation.method(#downloadFile, [ - url - ], { - #key: key, - #authHeaders: authHeaders, - #ignoreMemCache: ignoreMemCache - }), - returnValue: const Stream<_i10.FileResponse>.empty()) - as _i7.Stream<_i10.FileResponse>); + Invocation.method( + #downloadFile, + [url], + { + #key: key, + #authHeaders: authHeaders, + #ignoreMemCache: ignoreMemCache, + }, + ), + returnValue: _i5.Stream<_i4.FileResponse>.empty(), + ) as _i5.Stream<_i4.FileResponse>); } From 3e6a6bb424b59a67581c695c17be732dcf10d939 Mon Sep 17 00:00:00 2001 From: Carapacik Date: Tue, 20 Jun 2023 00:37:19 +0300 Subject: [PATCH 13/27] Update example --- flutter_cache_manager/example/.gitignore | 60 ++--- flutter_cache_manager/example/README.md | 9 +- .../example/analysis_options.yaml | 2 +- .../example/android/app/build.gradle | 11 +- .../android/app/src/debug/AndroidManifest.xml | 6 +- .../android/app/src/main/AndroidManifest.xml | 16 +- .../example/MainActivity.kt | 2 +- .../app/src/main/res/values-night/styles.xml | 4 +- .../app/src/main/res/values/styles.xml | 4 +- .../app/src/profile/AndroidManifest.xml | 6 +- .../example/android/build.gradle | 8 +- .../gradle/wrapper/gradle-wrapper.properties | 3 +- flutter_cache_manager/example/ios/.gitignore | 2 + .../ios/Flutter/AppFrameworkInfo.plist | 4 +- .../example/ios/Flutter/Debug.xcconfig | 2 +- .../example/ios/Flutter/Release.xcconfig | 2 +- flutter_cache_manager/example/ios/Podfile | 5 +- .../ios/Runner.xcodeproj/project.pbxproj | 249 +++++++++++------- .../xcshareddata/xcschemes/Runner.xcscheme | 21 +- .../contents.xcworkspacedata | 3 - .../AppIcon.appiconset/Icon-App-20x20@1x.png | Bin 564 -> 295 bytes .../AppIcon.appiconset/Icon-App-20x20@2x.png | Bin 1283 -> 406 bytes .../AppIcon.appiconset/Icon-App-20x20@3x.png | Bin 1588 -> 450 bytes .../AppIcon.appiconset/Icon-App-29x29@1x.png | Bin 1025 -> 282 bytes .../AppIcon.appiconset/Icon-App-29x29@2x.png | Bin 1716 -> 462 bytes .../AppIcon.appiconset/Icon-App-29x29@3x.png | Bin 1920 -> 704 bytes .../AppIcon.appiconset/Icon-App-40x40@1x.png | Bin 1283 -> 406 bytes .../AppIcon.appiconset/Icon-App-40x40@2x.png | Bin 1895 -> 586 bytes .../AppIcon.appiconset/Icon-App-40x40@3x.png | Bin 2665 -> 862 bytes .../AppIcon.appiconset/Icon-App-60x60@2x.png | Bin 2665 -> 862 bytes .../AppIcon.appiconset/Icon-App-60x60@3x.png | Bin 3831 -> 1674 bytes .../AppIcon.appiconset/Icon-App-76x76@1x.png | Bin 1888 -> 762 bytes .../AppIcon.appiconset/Icon-App-76x76@2x.png | Bin 3294 -> 1226 bytes .../Icon-App-83.5x83.5@2x.png | Bin 3612 -> 1418 bytes .../example/ios/Runner/Info.plist | 6 + .../example/ios/RunnerTests/RunnerTests.swift | 12 + .../lib/plugin_example/download_page.dart | 15 +- .../lib/plugin_example/file_info_widget.dart | 10 +- .../floating_action_button.dart | 7 +- .../example/linux/CMakeLists.txt | 49 +++- .../example/linux/flutter/CMakeLists.txt | 6 +- flutter_cache_manager/example/linux/main.cc | 4 - .../example/linux/my_application.cc | 68 ++++- flutter_cache_manager/example/macos/Podfile | 5 +- .../macos/Runner.xcodeproj/project.pbxproj | 191 +++++++++----- .../xcshareddata/xcschemes/Runner.xcscheme | 19 +- .../contents.xcworkspacedata | 3 - .../AppIcon.appiconset/app_icon_1024.png | Bin 46993 -> 102994 bytes .../AppIcon.appiconset/app_icon_128.png | Bin 3276 -> 5680 bytes .../AppIcon.appiconset/app_icon_16.png | Bin 1429 -> 520 bytes .../AppIcon.appiconset/app_icon_256.png | Bin 5933 -> 14142 bytes .../AppIcon.appiconset/app_icon_32.png | Bin 1243 -> 1066 bytes .../AppIcon.appiconset/app_icon_512.png | Bin 14800 -> 36406 bytes .../AppIcon.appiconset/app_icon_64.png | Bin 1874 -> 2218 bytes .../macos/Runner/Base.lproj/MainMenu.xib | 4 + .../macos/Runner/Configs/AppInfo.xcconfig | 4 +- .../macos/Runner/MainFlutterWindow.swift | 2 +- .../macos/RunnerTests/RunnerTests.swift | 12 + flutter_cache_manager/example/pubspec.yaml | 6 +- flutter_cache_manager/example/web/index.html | 46 +++- .../example/web/manifest.json | 14 +- .../example/windows/CMakeLists.txt | 23 +- .../example/windows/flutter/CMakeLists.txt | 5 +- .../example/windows/runner/CMakeLists.txt | 26 +- .../example/windows/runner/Runner.rc | 16 +- .../example/windows/runner/flutter_window.cpp | 14 +- .../example/windows/runner/flutter_window.h | 10 +- .../example/windows/runner/main.cpp | 19 +- .../example/windows/runner/run_loop.cpp | 66 ----- .../example/windows/runner/run_loop.h | 40 --- .../windows/runner/runner.exe.manifest | 2 +- .../example/windows/runner/utils.cpp | 43 +++ .../example/windows/runner/utils.h | 11 + .../example/windows/runner/win32_window.cpp | 58 +++- .../example/windows/runner/win32_window.h | 20 +- 75 files changed, 769 insertions(+), 486 deletions(-) rename flutter_cache_manager/example/android/app/src/main/kotlin/com/{example => baseflow}/example/MainActivity.kt (76%) create mode 100644 flutter_cache_manager/example/ios/RunnerTests/RunnerTests.swift create mode 100644 flutter_cache_manager/example/macos/RunnerTests/RunnerTests.swift delete mode 100644 flutter_cache_manager/example/windows/runner/run_loop.cpp delete mode 100644 flutter_cache_manager/example/windows/runner/run_loop.h diff --git a/flutter_cache_manager/example/.gitignore b/flutter_cache_manager/example/.gitignore index 01f4ac79..24476c5d 100644 --- a/flutter_cache_manager/example/.gitignore +++ b/flutter_cache_manager/example/.gitignore @@ -1,6 +1,5 @@ # Miscellaneous *.class -*.lock *.log *.pyc *.swp @@ -9,6 +8,7 @@ .buildlog/ .history .svn/ +migrate_working_dir/ # IntelliJ related *.iml @@ -16,57 +16,29 @@ *.iws .idea/ -# Visual Studio Code related -.vscode/ +# The .vscode folder contains launch configuration and tasks you configure in +# VS Code which you may wish to be included in version control, so this line +# is commented out by default. +#.vscode/ # Flutter/Dart/Pub related **/doc/api/ +**/ios/Flutter/.last_build_id .dart_tool/ .flutter-plugins +.flutter-plugins-dependencies .packages .pub-cache/ .pub/ -build/ +/build/ -# Android related -**/android/**/gradle-wrapper.jar -**/android/.gradle -**/android/captures/ -**/android/gradlew -**/android/gradlew.bat -**/android/local.properties -**/android/**/GeneratedPluginRegistrant.java +# Symbolication related +app.*.symbols -# iOS/XCode related -**/ios/**/*.mode1v3 -**/ios/**/*.mode2v3 -**/ios/**/*.moved-aside -**/ios/**/*.pbxuser -**/ios/**/*.perspectivev3 -**/ios/**/*sync/ -**/ios/**/.sconsign.dblite -**/ios/**/.tags* -**/ios/**/.vagrant/ -**/ios/**/DerivedData/ -**/ios/**/Icon? -**/ios/**/Pods/ -**/ios/**/.symlinks/ -**/ios/**/profile -**/ios/**/xcuserdata -**/ios/.generated/ -**/ios/Flutter/App.framework -**/ios/Flutter/Flutter.framework -**/ios/Flutter/Generated.xcconfig -**/ios/Flutter/app.flx -**/ios/Flutter/app.zip -**/ios/Flutter/flutter_assets/ -**/ios/Flutter/flutter_export_environment.sh -**/ios/ServiceDefinitions.json -**/ios/Runner/GeneratedPluginRegistrant.* +# Obfuscation related +app.*.map.json -# Exceptions to above rules. -!**/ios/**/default.mode1v3 -!**/ios/**/default.mode2v3 -!**/ios/**/default.pbxuser -!**/ios/**/default.perspectivev3 -!/packages/flutter_tools/test/data/dart_dependencies_test/**/.packages +# Android Studio will place build artifacts here +/android/app/debug +/android/app/profile +/android/app/release diff --git a/flutter_cache_manager/example/README.md b/flutter_cache_manager/example/README.md index 64a12f6b..75a7c517 100644 --- a/flutter_cache_manager/example/README.md +++ b/flutter_cache_manager/example/README.md @@ -1,8 +1 @@ -# example - -A new Flutter project. - -## Getting Started - -For help getting started with Flutter, view our online -[documentation](https://flutter.io/). +# A project that showcases usage of flutter_cache_manager diff --git a/flutter_cache_manager/example/analysis_options.yaml b/flutter_cache_manager/example/analysis_options.yaml index a3be6b82..f9b30346 100644 --- a/flutter_cache_manager/example/analysis_options.yaml +++ b/flutter_cache_manager/example/analysis_options.yaml @@ -1 +1 @@ -include: package:flutter_lints/flutter.yaml \ No newline at end of file +include: package:flutter_lints/flutter.yaml diff --git a/flutter_cache_manager/example/android/app/build.gradle b/flutter_cache_manager/example/android/app/build.gradle index b120248e..40d3166f 100644 --- a/flutter_cache_manager/example/android/app/build.gradle +++ b/flutter_cache_manager/example/android/app/build.gradle @@ -26,7 +26,9 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 31 + namespace "com.baseflow.example" + compileSdkVersion 33 + ndkVersion flutter.ndkVersion compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 @@ -42,10 +44,9 @@ android { } defaultConfig { - // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). - applicationId "com.example.example" - minSdkVersion 16 - targetSdkVersion 30 + applicationId "com.baseflow.example" + minSdkVersion 21 + targetSdkVersion 23 versionCode flutterVersionCode.toInteger() versionName flutterVersionName } diff --git a/flutter_cache_manager/example/android/app/src/debug/AndroidManifest.xml b/flutter_cache_manager/example/android/app/src/debug/AndroidManifest.xml index c208884f..399f6981 100644 --- a/flutter_cache_manager/example/android/app/src/debug/AndroidManifest.xml +++ b/flutter_cache_manager/example/android/app/src/debug/AndroidManifest.xml @@ -1,6 +1,6 @@ - - diff --git a/flutter_cache_manager/example/android/app/src/main/AndroidManifest.xml b/flutter_cache_manager/example/android/app/src/main/AndroidManifest.xml index 34dd77ef..19b862ec 100644 --- a/flutter_cache_manager/example/android/app/src/main/AndroidManifest.xml +++ b/flutter_cache_manager/example/android/app/src/main/AndroidManifest.xml @@ -1,10 +1,11 @@ - - + - - diff --git a/flutter_cache_manager/example/android/app/src/main/kotlin/com/example/example/MainActivity.kt b/flutter_cache_manager/example/android/app/src/main/kotlin/com/baseflow/example/MainActivity.kt similarity index 76% rename from flutter_cache_manager/example/android/app/src/main/kotlin/com/example/example/MainActivity.kt rename to flutter_cache_manager/example/android/app/src/main/kotlin/com/baseflow/example/MainActivity.kt index e793a000..1751a1f6 100644 --- a/flutter_cache_manager/example/android/app/src/main/kotlin/com/example/example/MainActivity.kt +++ b/flutter_cache_manager/example/android/app/src/main/kotlin/com/baseflow/example/MainActivity.kt @@ -1,4 +1,4 @@ -package com.example.example +package com.baseflow.example import io.flutter.embedding.android.FlutterActivity diff --git a/flutter_cache_manager/example/android/app/src/main/res/values-night/styles.xml b/flutter_cache_manager/example/android/app/src/main/res/values-night/styles.xml index 449a9f93..06952be7 100644 --- a/flutter_cache_manager/example/android/app/src/main/res/values-night/styles.xml +++ b/flutter_cache_manager/example/android/app/src/main/res/values-night/styles.xml @@ -3,14 +3,14 @@