diff --git a/flutter_cache_manager/analysis_options.yaml b/flutter_cache_manager/analysis_options.yaml index fce4255c..a3be6b82 100644 --- a/flutter_cache_manager/analysis_options.yaml +++ b/flutter_cache_manager/analysis_options.yaml @@ -1,91 +1 @@ -include: package:pedantic/analysis_options.1.8.0.yaml - -analyzer: - strong-mode: - implicit-casts: false - # implicit-dynamic: false - errors: - unused_import: warning - unused_local_variable: warning - dead_code: warning - invalid_override_of_non_virtual_member: error - -linter: - rules: - - always_declare_return_types - - annotate_overrides - - avoid_empty_else - - avoid_function_literals_in_foreach_calls - - avoid_init_to_null - - avoid_void_async - - await_only_futures - # - avoid_implementing_value_types - - avoid_null_checks_in_equality_operators - - avoid_renaming_method_parameters - - avoid_return_types_on_setters - - avoid_returning_null - - avoid_returning_null_for_void - - avoid_types_as_parameter_names - - avoid_relative_lib_imports - - avoid_unused_constructor_parameters - - camel_case_types - - cancel_subscriptions - #- cascade_invocations - #- comment_references - #- constant_identifier_names - - control_flow_in_finally - - directives_ordering - - empty_catches - - empty_constructor_bodies - - empty_statements - - hash_and_equals - #- implementation_imports - - invariant_booleans - - iterable_contains_unrelated_type - - library_names - - library_prefixes - - list_remove_unrelated_type - - no_adjacent_strings_in_list - - no_duplicate_case_values - - non_constant_identifier_names - - omit_local_variable_types - #- only_throw_errors - - overridden_fields - - package_api_docs - - package_names - - package_prefixed_library_names - - prefer_adjacent_string_concatenation - - prefer_collection_literals - - prefer_conditional_assignment - - prefer_const_constructors - - prefer_contains - - prefer_equal_for_default_values - - prefer_final_fields - - prefer_initializing_formals - #- prefer_int_literals - #- prefer_interpolation_to_compose_strings - - prefer_is_empty - - prefer_is_not_empty - - prefer_single_quotes - - prefer_typing_uninitialized_variables - - recursive_getters - - slash_for_doc_comments - - sort_pub_dependencies - - test_types_in_equals - - throw_in_finally - - type_init_formals - - unawaited_futures - - unnecessary_await_in_return - - unnecessary_brace_in_string_interps - - unnecessary_getters_setters - - unnecessary_lambdas - - unnecessary_null_aware_assignments - - unnecessary_statements - - unnecessary_this - - unrelated_type_equality_checks - - use_rethrow_when_possible - - valid_regexps - # Additional Dart 2.3 lints - - prefer_spread_collections - - prefer_if_elements_to_conditional_expressions - - prefer_for_elements_to_map_fromIterable +include: package:flutter_lints/flutter.yaml \ No newline at end of file diff --git a/flutter_cache_manager/example/analysis_options.yaml b/flutter_cache_manager/example/analysis_options.yaml index 61b6c4de..a3be6b82 100644 --- a/flutter_cache_manager/example/analysis_options.yaml +++ b/flutter_cache_manager/example/analysis_options.yaml @@ -1,29 +1 @@ -# This file configures the analyzer, which statically analyzes Dart code to -# check for errors, warnings, and lints. -# -# The issues identified by the analyzer are surfaced in the UI of Dart-enabled -# IDEs (https://dart.dev/tools#ides-and-editors). The analyzer can also be -# invoked from the command line by running `flutter analyze`. - -# The following line activates a set of recommended lints for Flutter apps, -# packages, and plugins designed to encourage good coding practices. -include: package:flutter_lints/flutter.yaml - -linter: - # The lint rules applied to this project can be customized in the - # section below to disable rules from the `package:flutter_lints/flutter.yaml` - # included above or to enable additional rules. A list of all available lints - # and their documentation is published at - # https://dart-lang.github.io/linter/lints/index.html. - # - # Instead of disabling a lint rule for the entire project in the - # section below, it can also be suppressed for a single line of code - # or a specific dart file by using the `// ignore: name_of_lint` and - # `// ignore_for_file: name_of_lint` syntax on the line or in the file - # producing the lint. - rules: - # avoid_print: false # Uncomment to disable the `avoid_print` rule - # prefer_single_quotes: true # Uncomment to enable the `prefer_single_quotes` rule - -# Additional information about this file can be found at -# https://dart.dev/guides/language/analysis-options +include: package:flutter_lints/flutter.yaml \ No newline at end of file diff --git a/flutter_cache_manager/example/ios/Flutter/AppFrameworkInfo.plist b/flutter_cache_manager/example/ios/Flutter/AppFrameworkInfo.plist index 6b4c0f78..f2872cf4 100644 --- a/flutter_cache_manager/example/ios/Flutter/AppFrameworkInfo.plist +++ b/flutter_cache_manager/example/ios/Flutter/AppFrameworkInfo.plist @@ -21,6 +21,6 @@ CFBundleVersion 1.0 MinimumOSVersion - 8.0 + 9.0 diff --git a/flutter_cache_manager/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/flutter_cache_manager/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata index 1d526a16..919434a6 100644 --- a/flutter_cache_manager/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/flutter_cache_manager/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -2,6 +2,6 @@ + location = "self:"> diff --git a/flutter_cache_manager/example/linux/flutter/generated_plugin_registrant.cc b/flutter_cache_manager/example/linux/flutter/generated_plugin_registrant.cc index 026851fa..f6f23bfe 100644 --- a/flutter_cache_manager/example/linux/flutter/generated_plugin_registrant.cc +++ b/flutter_cache_manager/example/linux/flutter/generated_plugin_registrant.cc @@ -2,6 +2,8 @@ // Generated file. Do not edit. // +// clang-format off + #include "generated_plugin_registrant.h" #include diff --git a/flutter_cache_manager/example/linux/flutter/generated_plugin_registrant.h b/flutter_cache_manager/example/linux/flutter/generated_plugin_registrant.h index 9bf74789..e0f0a47b 100644 --- a/flutter_cache_manager/example/linux/flutter/generated_plugin_registrant.h +++ b/flutter_cache_manager/example/linux/flutter/generated_plugin_registrant.h @@ -2,6 +2,8 @@ // Generated file. Do not edit. // +// clang-format off + #ifndef GENERATED_PLUGIN_REGISTRANT_ #define GENERATED_PLUGIN_REGISTRANT_ diff --git a/flutter_cache_manager/lib/src/cache_manager.dart b/flutter_cache_manager/lib/src/cache_manager.dart index f0ca48a0..10529cd0 100644 --- a/flutter_cache_manager/lib/src/cache_manager.dart +++ b/flutter_cache_manager/lib/src/cache_manager.dart @@ -12,7 +12,6 @@ import 'package:flutter_cache_manager/src/result/file_info.dart'; import 'package:flutter_cache_manager/src/result/file_response.dart'; import 'package:flutter_cache_manager/src/storage/cache_object.dart'; import 'package:flutter_cache_manager/src/web/web_helper.dart'; -import 'package:pedantic/pedantic.dart'; import 'package:uuid/uuid.dart'; import 'config/config.dart'; diff --git a/flutter_cache_manager/lib/src/cache_store.dart b/flutter_cache_manager/lib/src/cache_store.dart index d3fc2db9..930cecc7 100644 --- a/flutter_cache_manager/lib/src/cache_store.dart +++ b/flutter_cache_manager/lib/src/cache_store.dart @@ -2,7 +2,6 @@ import 'dart:async'; import 'package:flutter_cache_manager/src/config/config.dart'; import 'package:flutter_cache_manager/src/storage/file_system/file_system.dart'; -import 'package:pedantic/pedantic.dart'; import '../flutter_cache_manager.dart'; import 'logger.dart'; @@ -86,7 +85,7 @@ class CacheStore { _memCache[key] = cacheObject; } completer.complete(cacheObject); - unawaited(_futureCache.remove(key)); + _futureCache.remove(key); })); _futureCache[key] = completer.future; } @@ -183,7 +182,7 @@ class CacheStore { _memCache.remove(cacheObject.key); } if (_futureCache.containsKey(cacheObject.key)) { - unawaited(_futureCache.remove(cacheObject.key)); + _futureCache.remove(cacheObject.key); } final file = await fileSystem.createFile(cacheObject.relativePath); if (await file.exists()) { diff --git a/flutter_cache_manager/lib/src/compat/file_fetcher.dart b/flutter_cache_manager/lib/src/compat/file_fetcher.dart index acf3e42b..59e44b9d 100644 --- a/flutter_cache_manager/lib/src/compat/file_fetcher.dart +++ b/flutter_cache_manager/lib/src/compat/file_fetcher.dart @@ -8,7 +8,7 @@ import 'package:http/http.dart' as http; ///Released under MIT License. /// Deprecated FileFetcher function -typedef Future FileFetcher(String url, +typedef FileFetcher = Future Function(String url, {Map? headers}); abstract class FileFetcherResponse { diff --git a/flutter_cache_manager/lib/src/logger.dart b/flutter_cache_manager/lib/src/logger.dart index 312b16de..c5878f8d 100644 --- a/flutter_cache_manager/lib/src/logger.dart +++ b/flutter_cache_manager/lib/src/logger.dart @@ -17,6 +17,7 @@ class CacheLogger { /// Function to log a message on a certain loglevel void log(String message, CacheManagerLogLevel level) { if (CacheManager.logLevel.index >= level.index) { + // ignore: avoid_print print(message); } } diff --git a/flutter_cache_manager/lib/src/result/file_info.dart b/flutter_cache_manager/lib/src/result/file_info.dart index e4d4ef15..1023e3ef 100644 --- a/flutter_cache_manager/lib/src/result/file_info.dart +++ b/flutter_cache_manager/lib/src/result/file_info.dart @@ -6,6 +6,7 @@ import 'package:flutter_cache_manager/src/result/file_response.dart'; ///Released under MIT License. /// Enum for whether the file is coming from the cache or is just downloaded. +// ignore: constant_identifier_names enum FileSource { NA, Cache, Online } /// FileInfo contains the fetch File next to some info on the validity and diff --git a/flutter_cache_manager/lib/src/web/web_helper.dart b/flutter_cache_manager/lib/src/web/web_helper.dart index 4c4e36fd..f973905a 100644 --- a/flutter_cache_manager/lib/src/web/web_helper.dart +++ b/flutter_cache_manager/lib/src/web/web_helper.dart @@ -12,7 +12,6 @@ import 'package:flutter_cache_manager/src/result/file_response.dart'; import 'package:flutter_cache_manager/src/storage/cache_object.dart'; import 'package:flutter_cache_manager/src/web/file_service.dart'; import 'package:flutter_cache_manager/src/web/queue_item.dart'; -import 'package:pedantic/pedantic.dart'; import 'package:rxdart/rxdart.dart'; import 'package:uuid/uuid.dart'; diff --git a/flutter_cache_manager/pubspec.yaml b/flutter_cache_manager/pubspec.yaml index 0d895bb6..124d2745 100644 --- a/flutter_cache_manager/pubspec.yaml +++ b/flutter_cache_manager/pubspec.yaml @@ -15,7 +15,6 @@ dependencies: http: ^0.13.0 path: ^1.8.0 path_provider: ^2.0.0 - pedantic: ^1.10.0 rxdart: ">=0.26.0 <0.28.0" sqflite: ^2.0.0+3 uuid: ^3.0.0 @@ -25,3 +24,4 @@ dev_dependencies: flutter_test: sdk: flutter mockito: ^5.0.0 + flutter_lints: ^1.0.4 diff --git a/flutter_cache_manager/test/cache_manager_test.dart b/flutter_cache_manager/test/cache_manager_test.dart index ad3587e1..fd18ec7b 100644 --- a/flutter_cache_manager/test/cache_manager_test.dart +++ b/flutter_cache_manager/test/cache_manager_test.dart @@ -1,6 +1,5 @@ import 'dart:async'; import 'dart:typed_data'; -import 'dart:ui'; import 'package:clock/clock.dart'; import 'package:file/memory.dart'; @@ -490,8 +489,7 @@ void main() { var fileUrl = 'baseflow.com/test'; var store = MockCacheStore(); - when(store.putFile(argThat(anything))) - .thenAnswer((_) => Future.value(VoidCallback)); + when(store.putFile(argThat(anything))).thenAnswer((_) => Future.value()); when(store.getFile(fileUrl)).thenAnswer((_) => Future.value(null)); diff --git a/flutter_cache_manager/test/cache_object_test.dart b/flutter_cache_manager/test/cache_object_test.dart index 3b2acb9b..d6d51c3c 100644 --- a/flutter_cache_manager/test/cache_object_test.dart +++ b/flutter_cache_manager/test/cache_object_test.dart @@ -15,11 +15,11 @@ void main() { final validDate = DateTime.utc(2020, 03, 27, 09, 26).toLocal(); final now = DateTime(2020, 03, 28, 09, 26); - final testId = 1; - final relativePath = 'test.png'; - final testUrl = 'www.test.com/image'; - final testKey = 'test123'; - final eTag = 'test1'; + const testId = 1; + const relativePath = 'test.png'; + const testUrl = 'www.test.com/image'; + const testKey = 'test123'; + const eTag = 'test1'; test('constructor, no explicit key', () { final object = CacheObject( diff --git a/flutter_cache_manager/test/helpers/json_repo_helpers.dart b/flutter_cache_manager/test/helpers/json_repo_helpers.dart index a3a6b477..cf3494c6 100644 --- a/flutter_cache_manager/test/helpers/json_repo_helpers.dart +++ b/flutter_cache_manager/test/helpers/json_repo_helpers.dart @@ -45,7 +45,7 @@ class JsonRepoHelpers { } static final defaultValidTill = clock.now().add(const Duration(days: 7)); - static final defaultRelativePath = 'test.png'; + static const defaultRelativePath = 'test.png'; static final List startCacheObjects = [ // Old object CacheObject( diff --git a/flutter_cache_manager/test/web_helper_test.dart b/flutter_cache_manager/test/web_helper_test.dart index 3b1c0631..dc59e510 100644 --- a/flutter_cache_manager/test/web_helper_test.dart +++ b/flutter_cache_manager/test/web_helper_test.dart @@ -1,5 +1,4 @@ import 'dart:async'; -import 'dart:ui'; import 'package:clock/clock.dart'; import 'package:flutter_cache_manager/flutter_cache_manager.dart'; @@ -232,8 +231,7 @@ void main() { MockCacheStore _createStore(Config config) { final store = MockCacheStore(); - when(store.putFile(argThat(anything))) - .thenAnswer((_) => Future.value(VoidCallback)); + when(store.putFile(argThat(anything))).thenAnswer((_) => Future.value()); when(store.retrieveCacheData(argThat(anything))) .thenAnswer((invocation) => Future.value(CacheObject( invocation.positionalArguments.first as String,