diff --git a/.ci/Dockerfile b/.ci/Dockerfile index 0eae7323..f9e45816 100644 --- a/.ci/Dockerfile +++ b/.ci/Dockerfile @@ -1,7 +1,7 @@ # The Flutter version is not important here, since the CI scripts update Flutter # before running. What matters is that the base image is pinned to minimize # unintended changes when modifying this file. -FROM cirrusci/flutter:2.2.2 +FROM cirrusci/flutter:stable RUN apt-get update -y @@ -41,6 +41,7 @@ RUN wget -q -O - https://dl-ssl.google.com/linux/linux_signing_key.pub | sudo ap RUN echo 'deb [arch=amd64] http://dl.google.com/linux/chrome/deb/ stable main' | sudo tee /etc/apt/sources.list.d/google-chrome.list RUN apt-get update && apt-get install -y --no-install-recommends google-chrome-stable -# Make Chrome the default so http: has a handler for url_launcher tests. +# Make Chrome the default so http: and file: has a handler for url_launcher tests. RUN apt-get install -y xdg-utils RUN xdg-settings set default-web-browser google-chrome.desktop +RUN xdg-mime default google-chrome.desktop inode/directory diff --git a/analysis_options.yaml b/analysis_options.yaml deleted file mode 100644 index c2dcf2c2..00000000 --- a/analysis_options.yaml +++ /dev/null @@ -1,123 +0,0 @@ -analyzer: - exclude: - - '**/*.g.dart' - - '**/generated_plugin_registrant.dart' - - '**/pigeon.dart' - strong-mode: - implicit-casts: true - implicit-dynamic: true - errors: - always_declare_return_types: warning - camel_case_types: warning - empty_constructor_bodies: warning - annotate_overrides: warning - avoid_init_to_null: warning - constant_identifier_names: warning - slash_for_doc_comments: warning - type_annotate_public_apis: warning - type_init_formals: warning - sort_constructors_first: warning - sort_unnamed_constructors_first: warning - unnecessary_brace_in_string_interps: warning - no_duplicate_case_values: warning - prefer_void_to_null: warning - lines_longer_than_80_chars: warning - always_put_control_body_on_new_line: warning - unnecessary_await_in_return: warning - use_to_and_as_if_applicable: warning - valid_regexps: warning - throw_in_finally: warning - use_full_hex_values_for_flutter_colors: warning - use_function_type_syntax_for_parameters: warning - use_rethrow_when_possible: warning - use_setters_to_change_properties: warning - use_string_buffers: warning - -linter: - rules: - - always_declare_return_types - - always_put_control_body_on_new_line - - always_put_required_named_parameters_first - - always_require_non_null_named_parameters - - avoid_annotating_with_dynamic - - avoid_returning_this - - avoid_classes_with_only_static_members - - annotate_overrides - - avoid_empty_else - - avoid_init_to_null - - avoid_null_checks_in_equality_operators - - avoid_return_types_on_setters - - avoid_slow_async_io - - avoid_unused_constructor_parameters - - await_only_futures - - prefer_expression_function_bodies - - camel_case_types - - cancel_subscriptions - - cascade_invocations - - comment_references - - control_flow_in_finally - - directives_ordering - - file_names - - flutter_style_todos - - empty_catches - - empty_constructor_bodies - - empty_statements - - hash_and_equals - - implementation_imports - - invariant_booleans - - iterable_contains_unrelated_type - - join_return_with_assignment - - library_names - - list_remove_unrelated_type - - literal_only_boolean_expressions - - no_adjacent_strings_in_list - - no_duplicate_case_values - - non_constant_identifier_names - - library_prefixes - - only_throw_errors - - package_names - - package_prefixed_library_names - - parameter_assignments - - prefer_adjacent_string_concatenation - - prefer_asserts_in_initializer_lists - - prefer_contains - - prefer_final_fields - - prefer_final_locals - - prefer_foreach - - prefer_function_declarations_over_variables - - prefer_initializing_formals - - prefer_is_empty - - prefer_is_not_empty - - prefer_single_quotes - - prefer_typing_uninitialized_variables - - prefer_null_aware_operators - - prefer_spread_collections - - provide_deprecation_message - - recursive_getters - - slash_for_doc_comments - - sort_constructors_first - - sort_unnamed_constructors_first - - test_types_in_equals - - throw_in_finally - - type_annotate_public_apis - - type_init_formals - - unnecessary_brace_in_string_interps - - unnecessary_getters_setters - - unnecessary_lambdas - - unnecessary_null_aware_assignments - - unnecessary_null_in_if_null_operators - - unnecessary_overrides - - unnecessary_statements - - unnecessary_new - - unnecessary_this - - unnecessary_parenthesis - - unnecessary_await_in_return - - lines_longer_than_80_chars - - unrelated_type_equality_checks - - use_full_hex_values_for_flutter_colors - - use_function_type_syntax_for_parameters - - use_rethrow_when_possible - - use_setters_to_change_properties - - use_string_buffers - - use_to_and_as_if_applicable - - valid_regexps diff --git a/packages/auto_animated/analysis_options.yaml b/packages/auto_animated/analysis_options.yaml deleted file mode 100644 index f04c6cf0..00000000 --- a/packages/auto_animated/analysis_options.yaml +++ /dev/null @@ -1 +0,0 @@ -include: ../../analysis_options.yaml diff --git a/packages/auto_animated/example/android/app/build.gradle b/packages/auto_animated/example/android/app/build.gradle index c7b36c77..41d2b88a 100644 --- a/packages/auto_animated/example/android/app/build.gradle +++ b/packages/auto_animated/example/android/app/build.gradle @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 29 + compileSdkVersion 31 sourceSets { main.java.srcDirs += 'src/main/kotlin' @@ -40,7 +40,7 @@ android { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "io.scer.auto_animated_example" minSdkVersion 16 - targetSdkVersion 29 + targetSdkVersion 21 versionCode flutterVersionCode.toInteger() versionName flutterVersionName } diff --git a/packages/auto_animated/example/android/app/src/main/AndroidManifest.xml b/packages/auto_animated/example/android/app/src/main/AndroidManifest.xml index ee4a21e0..c9cad32d 100644 --- a/packages/auto_animated/example/android/app/src/main/AndroidManifest.xml +++ b/packages/auto_animated/example/android/app/src/main/AndroidManifest.xml @@ -1,47 +1,46 @@ - - - - - - - - - - - - - - - - + + diff --git a/packages/auto_animated/example/ios/Runner.xcodeproj/project.pbxproj b/packages/auto_animated/example/ios/Runner.xcodeproj/project.pbxproj index ec330f6d..fafa0576 100644 --- a/packages/auto_animated/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/auto_animated/example/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 46; + objectVersion = 50; objects = { /* Begin PBXBuildFile section */ @@ -288,13 +288,17 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = 7D294NMXAJ; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", ); INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", @@ -407,7 +411,8 @@ MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; - SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; }; @@ -420,13 +425,17 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = 7D294NMXAJ; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", ); INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", @@ -447,13 +456,17 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = 7D294NMXAJ; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", ); INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", diff --git a/packages/auto_animated/lib/src/animate_if_visible.dart b/packages/auto_animated/lib/src/animate_if_visible.dart index e2179b9d..7f778381 100644 --- a/packages/auto_animated/lib/src/animate_if_visible.dart +++ b/packages/auto_animated/lib/src/animate_if_visible.dart @@ -38,7 +38,7 @@ class AnimateIfVisible extends StatefulWidget { final bool reAnimateOnVisibility; @override - _AnimateIfVisibleState createState() => _AnimateIfVisibleState(); + State createState() => _AnimateIfVisibleState(); } class _AnimateIfVisibleState extends State @@ -69,11 +69,11 @@ class _AnimateIfVisibleState extends State @override Widget build(BuildContext context) => VisibilityDetector( key: widget.key!, + onVisibilityChanged: _visibilityChanged, child: widget.builder( context, _controller.view, ), - onVisibilityChanged: _visibilityChanged, ); void _visibilityChanged(VisibilityInfo info) { @@ -120,7 +120,7 @@ class AnimateIfVisibleWrapper extends StatefulWidget { final Duration delay, showItemInterval; @override - _AnimateIfVisibleWrapperState createState() => + State createState() => _AnimateIfVisibleWrapperState(); } @@ -159,8 +159,8 @@ class _AnimateIfVisibleWrapperState extends State { Widget build(BuildContext context) => _VisibilityStackProvider( stack: _stack, child: NotificationListener( - child: widget.child, onNotification: _handleScrollNotifications, + child: widget.child, ), ); @@ -201,7 +201,7 @@ class _AnimateIfVisibleWrapperState extends State { } class _VisibilityStackProvider extends InheritedWidget { - _VisibilityStackProvider({ + const _VisibilityStackProvider({ required Widget child, required this.stack, Key? key, diff --git a/packages/auto_animated/lib/src/animator/stack.dart b/packages/auto_animated/lib/src/animator/stack.dart index 325eb04b..47c07300 100644 --- a/packages/auto_animated/lib/src/animator/stack.dart +++ b/packages/auto_animated/lib/src/animator/stack.dart @@ -1,16 +1,16 @@ import 'package:flutter/widgets.dart' hide Stack; -class _Animatable { - _Animatable(this.key, this.callback); +class Animatable { + Animatable(this.key, this.callback); final Key? key; final VoidCallback callback; } -class _DirectionStack { - _DirectionStack(this.items, this.direction); +class DirectionStack { + DirectionStack(this.items, this.direction); - final List<_Animatable> items; + final List items; final AnimationDirection direction; } @@ -27,7 +27,7 @@ class VisibilityStack { AnimationDirection.toStart: false, }; - _DirectionStack _stack = _DirectionStack([], AnimationDirection.toEnd); + DirectionStack _stack = DirectionStack([], AnimationDirection.toEnd); final Map _alreadyAnimated = {}; AnimationDirection _direction = AnimationDirection.toEnd; @@ -37,15 +37,15 @@ class VisibilityStack { return; } animate( - _DirectionStack(List.from(_stack.items), _stack.direction), + DirectionStack(List.from(_stack.items), _stack.direction), showItemInterval ~/ 10, ); - _stack = _DirectionStack([], direction); + _stack = DirectionStack([], direction); _direction = direction; } void add(Key? key, VoidCallback callback) { - _stack.items.add(_Animatable(key, callback)); + _stack.items.add(Animatable(key, callback)); _alreadyAnimated[key] = false; @@ -55,8 +55,8 @@ class VisibilityStack { } } - void show(_DirectionStack stack) { - _Animatable animatable; + void show(DirectionStack stack) { + Animatable animatable; if (stack.direction == AnimationDirection.toEnd) { animatable = stack.items.first; stack.items.removeAt(0); @@ -70,7 +70,7 @@ class VisibilityStack { bool isAlreadyAnimated(Key? key) => _alreadyAnimated[key] ?? false; - void animate(_DirectionStack stack, Duration showItemInterval) { + void animate(DirectionStack stack, Duration showItemInterval) { if (_isAnimatedTo[stack.direction]!) { return; } @@ -95,8 +95,8 @@ class VisibilityStack { } @override - bool operator ==(Object o) => - o is VisibilityStack && showItemInterval == o.showItemInterval; + bool operator ==(Object other) => + other is VisibilityStack && showItemInterval == other.showItemInterval; @override int get hashCode => showItemInterval.hashCode; diff --git a/packages/auto_animated/lib/src/grid.dart b/packages/auto_animated/lib/src/grid.dart index d62df9a4..b1123170 100644 --- a/packages/auto_animated/lib/src/grid.dart +++ b/packages/auto_animated/lib/src/grid.dart @@ -206,7 +206,7 @@ class LiveGrid extends StatefulWidget { final bool addSemanticIndexes; @override - _LiveGridViewState createState() => _LiveGridViewState(); + State createState() => _LiveGridViewState(); } class _LiveGridViewState extends State diff --git a/packages/auto_animated/lib/src/icon_button.dart b/packages/auto_animated/lib/src/icon_button.dart index bf79a98b..e6fc23bb 100644 --- a/packages/auto_animated/lib/src/icon_button.dart +++ b/packages/auto_animated/lib/src/icon_button.dart @@ -11,7 +11,7 @@ enum IconState { first, second } ///[icon] cannot be null. ///[duration] is the time taken to animate the transition. class LiveIconButton extends StatefulWidget { - LiveIconButton({ + const LiveIconButton({ required this.icon, required this.onPressed, Key? key, @@ -33,7 +33,7 @@ class LiveIconButton extends StatefulWidget { }) : iconState = null, super(key: key); - LiveIconButton.externalState({ + const LiveIconButton.externalState({ required this.icon, required this.onPressed, required this.iconState, @@ -69,7 +69,7 @@ class LiveIconButton extends StatefulWidget { final IconState? iconState; @override - _LiveIconButtonState createState() => _LiveIconButtonState(); + State createState() => _LiveIconButtonState(); } class _LiveIconButtonState extends State diff --git a/packages/auto_animated/lib/src/sliver_grid.dart b/packages/auto_animated/lib/src/sliver_grid.dart index 55946ecf..434d1b17 100644 --- a/packages/auto_animated/lib/src/sliver_grid.dart +++ b/packages/auto_animated/lib/src/sliver_grid.dart @@ -82,7 +82,7 @@ class LiveSliverGrid extends StatefulWidget { final SliverGridDelegate gridDelegate; @override - _LiveSliverGridState createState() => _LiveSliverGridState(); + State createState() => _LiveSliverGridState(); } class _LiveSliverGridState extends State diff --git a/packages/auto_animated/lib/src/sliver_list.dart b/packages/auto_animated/lib/src/sliver_list.dart index 4b4624e0..b4fa5237 100644 --- a/packages/auto_animated/lib/src/sliver_list.dart +++ b/packages/auto_animated/lib/src/sliver_list.dart @@ -72,7 +72,7 @@ class LiveSliverList extends StatefulWidget { final int itemCount; @override - _LiveSliverListState createState() => _LiveSliverListState(); + State createState() => _LiveSliverListState(); } class _LiveSliverListState extends State diff --git a/packages/auto_animated/pubspec.lock b/packages/auto_animated/pubspec.lock index a0091c5c..142163d2 100644 --- a/packages/auto_animated/pubspec.lock +++ b/packages/auto_animated/pubspec.lock @@ -55,11 +55,25 @@ packages: description: flutter source: sdk version: "0.0.0" + flutter_lints: + dependency: "direct dev" + description: + name: flutter_lints + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.1" flutter_test: dependency: "direct dev" description: flutter source: sdk version: "0.0.0" + lints: + dependency: transitive + description: + name: lints + url: "https://pub.dartlang.org" + source: hosted + version: "2.0.0" matcher: dependency: transitive description: @@ -88,13 +102,6 @@ packages: url: "https://pub.dartlang.org" source: hosted version: "1.8.1" - pedantic: - dependency: "direct dev" - description: - name: pedantic - url: "https://pub.dartlang.org" - source: hosted - version: "1.11.0" sky_engine: dependency: transitive description: flutter @@ -157,5 +164,5 @@ packages: source: hosted version: "0.3.3" sdks: - dart: ">=2.17.0-0 <3.0.0" + dart: ">=2.17.0-206.0.dev <3.0.0" flutter: ">=2.12.0" diff --git a/packages/auto_animated/pubspec.yaml b/packages/auto_animated/pubspec.yaml index dd6b2c38..49589bfd 100644 --- a/packages/auto_animated/pubspec.yaml +++ b/packages/auto_animated/pubspec.yaml @@ -16,4 +16,4 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - pedantic: ^1.11.0 + flutter_lints: ^2.0.1 diff --git a/packages/epub_view/example/android/app/src/main/AndroidManifest.xml b/packages/epub_view/example/android/app/src/main/AndroidManifest.xml index 77eba674..c0af8d8a 100644 --- a/packages/epub_view/example/android/app/src/main/AndroidManifest.xml +++ b/packages/epub_view/example/android/app/src/main/AndroidManifest.xml @@ -1,46 +1,46 @@ - - - - - - - - - - - - - - - - + + diff --git a/packages/epub_view/example/android/gradle.properties b/packages/epub_view/example/android/gradle.properties index a6738207..94adc3a3 100644 --- a/packages/epub_view/example/android/gradle.properties +++ b/packages/epub_view/example/android/gradle.properties @@ -1,4 +1,3 @@ org.gradle.jvmargs=-Xmx1536M android.useAndroidX=true android.enableJetifier=true -android.enableR8=true diff --git a/packages/epub_view/example/ios/Flutter/Debug.xcconfig b/packages/epub_view/example/ios/Flutter/Debug.xcconfig index e8efba11..592ceee8 100644 --- a/packages/epub_view/example/ios/Flutter/Debug.xcconfig +++ b/packages/epub_view/example/ios/Flutter/Debug.xcconfig @@ -1,2 +1 @@ -#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "Generated.xcconfig" diff --git a/packages/epub_view/example/ios/Flutter/Release.xcconfig b/packages/epub_view/example/ios/Flutter/Release.xcconfig index 399e9340..c4855bfe 100644 --- a/packages/epub_view/example/ios/Flutter/Release.xcconfig +++ b/packages/epub_view/example/ios/Flutter/Release.xcconfig @@ -1,2 +1,2 @@ -#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "Generated.xcconfig" diff --git a/packages/epub_view/example/ios/Podfile b/packages/epub_view/example/ios/Podfile deleted file mode 100644 index 1e8c3c90..00000000 --- a/packages/epub_view/example/ios/Podfile +++ /dev/null @@ -1,41 +0,0 @@ -# Uncomment this line to define a global platform for your project -# platform :ios, '9.0' - -# CocoaPods analytics sends network stats synchronously affecting flutter build latency. -ENV['COCOAPODS_DISABLE_STATS'] = 'true' - -project 'Runner', { - 'Debug' => :debug, - 'Profile' => :release, - 'Release' => :release, -} - -def flutter_root - generated_xcode_build_settings_path = File.expand_path(File.join('..', 'Flutter', 'Generated.xcconfig'), __FILE__) - unless File.exist?(generated_xcode_build_settings_path) - raise "#{generated_xcode_build_settings_path} must exist. If you're running pod install manually, make sure flutter pub get is executed first" - end - - File.foreach(generated_xcode_build_settings_path) do |line| - matches = line.match(/FLUTTER_ROOT\=(.*)/) - return matches[1].strip if matches - end - raise "FLUTTER_ROOT not found in #{generated_xcode_build_settings_path}. Try deleting Generated.xcconfig, then run flutter pub get" -end - -require File.expand_path(File.join('packages', 'flutter_tools', 'bin', 'podhelper'), flutter_root) - -flutter_ios_podfile_setup - -target 'Runner' do - use_frameworks! - use_modular_headers! - - flutter_install_all_ios_pods File.dirname(File.realpath(__FILE__)) -end - -post_install do |installer| - installer.pods_project.targets.each do |target| - flutter_additional_ios_build_settings(target) - end -end diff --git a/packages/epub_view/example/ios/Runner.xcodeproj/project.pbxproj b/packages/epub_view/example/ios/Runner.xcodeproj/project.pbxproj index 8caa6663..90867639 100644 --- a/packages/epub_view/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/epub_view/example/ios/Runner.xcodeproj/project.pbxproj @@ -288,13 +288,17 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = 7D294NMXAJ; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", ); INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", @@ -420,13 +424,17 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = 7D294NMXAJ; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", ); INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", @@ -447,13 +455,17 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = 7D294NMXAJ; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", ); INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", diff --git a/packages/epub_view/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata b/packages/epub_view/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata index 1d526a16..919434a6 100644 --- a/packages/epub_view/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata +++ b/packages/epub_view/example/ios/Runner.xcodeproj/project.xcworkspace/contents.xcworkspacedata @@ -2,6 +2,6 @@ + location = "self:"> diff --git a/packages/epub_view/example/ios/Runner/Info.plist b/packages/epub_view/example/ios/Runner/Info.plist index b064f8e4..7c8beaca 100644 --- a/packages/epub_view/example/ios/Runner/Info.plist +++ b/packages/epub_view/example/ios/Runner/Info.plist @@ -41,5 +41,7 @@ UIViewControllerBasedStatusBarAppearance + CADisableMinimumFrameDurationOnPhone + diff --git a/packages/epub_view/example/lib/main.dart b/packages/epub_view/example/lib/main.dart index 316f4f38..8aefe1f5 100644 --- a/packages/epub_view/example/lib/main.dart +++ b/packages/epub_view/example/lib/main.dart @@ -8,19 +8,19 @@ class MyApp extends StatefulWidget { const MyApp({Key? key}) : super(key: key); @override - _MyAppState createState() => _MyAppState(); + State createState() => _MyAppState(); } class _MyAppState extends State with WidgetsBindingObserver { @override void initState() { - WidgetsBinding.instance!.addObserver(this); + WidgetsBinding.instance.addObserver(this); super.initState(); } @override void dispose() { - WidgetsBinding.instance!.removeObserver(this); + WidgetsBinding.instance.removeObserver(this); super.dispose(); } @@ -30,7 +30,7 @@ class _MyAppState extends State with WidgetsBindingObserver { } Brightness get platformBrightness => - MediaQueryData.fromWindow(WidgetsBinding.instance!.window) + MediaQueryData.fromWindow(WidgetsBinding.instance.window) .platformBrightness; void _setSystemUIOverlayStyle() { @@ -71,7 +71,7 @@ class MyHomePage extends StatefulWidget { const MyHomePage({Key? key}) : super(key: key); @override - _MyHomePageState createState() => _MyHomePageState(); + State createState() => _MyHomePageState(); } class _MyHomePageState extends State { diff --git a/packages/epub_view/example/macos/Flutter/Flutter-Debug.xcconfig b/packages/epub_view/example/macos/Flutter/Flutter-Debug.xcconfig index 785633d3..4b81f9b2 100644 --- a/packages/epub_view/example/macos/Flutter/Flutter-Debug.xcconfig +++ b/packages/epub_view/example/macos/Flutter/Flutter-Debug.xcconfig @@ -1,2 +1,2 @@ -#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig" #include "ephemeral/Flutter-Generated.xcconfig" diff --git a/packages/epub_view/example/macos/Flutter/Flutter-Release.xcconfig b/packages/epub_view/example/macos/Flutter/Flutter-Release.xcconfig index 5fba960c..5caa9d15 100644 --- a/packages/epub_view/example/macos/Flutter/Flutter-Release.xcconfig +++ b/packages/epub_view/example/macos/Flutter/Flutter-Release.xcconfig @@ -1,2 +1,2 @@ -#include "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" +#include? "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig" #include "ephemeral/Flutter-Generated.xcconfig" diff --git a/packages/epub_view/example/macos/Runner.xcodeproj/project.pbxproj b/packages/epub_view/example/macos/Runner.xcodeproj/project.pbxproj index f40edc8f..4ae41b8e 100644 --- a/packages/epub_view/example/macos/Runner.xcodeproj/project.pbxproj +++ b/packages/epub_view/example/macos/Runner.xcodeproj/project.pbxproj @@ -53,7 +53,6 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ - 1A828E88291E0255E3C5C0EE /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = ""; }; 333000ED22D3DE5D00554162 /* Warnings.xcconfig */ = {isa = PBXFileReference; lastKnownFileType = text.xcconfig; path = Warnings.xcconfig; sourceTree = ""; }; 335BBD1A22A9A15E00E9071D /* GeneratedPluginRegistrant.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = GeneratedPluginRegistrant.swift; sourceTree = ""; }; 33CC10ED2044A3C60003C045 /* example.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = example.app; sourceTree = BUILT_PRODUCTS_DIR; }; @@ -125,7 +124,7 @@ 33CC10F72044A3C60003C045 /* Info.plist */, ); name = Resources; - path = ..; + path = ".."; sourceTree = ""; }; 33CEB47122A05771004F2AC0 /* Flutter */ = { @@ -155,7 +154,6 @@ 9E92657B03D288ADB0E6F760 /* Pods */ = { isa = PBXGroup; children = ( - 1A828E88291E0255E3C5C0EE /* Pods-Runner.debug.xcconfig */, 404166CBA502B7EC446DC0CD /* Pods-Runner.release.xcconfig */, 7C51F405D3249123B58E9B51 /* Pods-Runner.profile.xcconfig */, ); diff --git a/packages/epub_view/lib/src/data/epub_cfi/_generator.dart b/packages/epub_view/lib/src/data/epub_cfi/_generator.dart index 0b1a215d..89dd4b48 100644 --- a/packages/epub_view/lib/src/data/epub_cfi/_generator.dart +++ b/packages/epub_view/lib/src/data/epub_cfi/_generator.dart @@ -53,13 +53,9 @@ class EpubCfiGenerator { // Create CFI step with id assertion, if the element has an id if (currentNode.attributes.containsKey('id')) { - elementStep = '/' + - cfiPosition.toString() + - '[' + - currentNode.attributes['id']! + - ']'; + elementStep = '/$cfiPosition[${currentNode.attributes['id']!}]'; } else { - elementStep = '/' + cfiPosition.toString(); + elementStep = '/$cfiPosition'; } // If a parent is an html element return the (last) step for this content @@ -78,7 +74,7 @@ class EpubCfiGenerator { // element may require an indirection // step to navigate to, thus requiring that ! is always prepend. if (topLevelElement == 'html') { - return '!' + elementStep; + return '!$elementStep'; } else { return elementStep; } diff --git a/packages/epub_view/lib/src/data/epub_cfi/_parser.dart b/packages/epub_view/lib/src/data/epub_cfi/_parser.dart index 8fa88186..1e0825ab 100644 --- a/packages/epub_view/lib/src/data/epub_cfi/_parser.dart +++ b/packages/epub_view/lib/src/data/epub_cfi/_parser.dart @@ -21,22 +21,18 @@ class EpubCfiParser { * because JSHint does not like the first and IE the second. */ static String quote(String s) => - '"' + - s - .replaceAll(RegExp(r'\\'), '\\\\') // backslash + '"${s.replaceAll(RegExp(r'\\'), '\\\\') // backslash .replaceAll(RegExp(r'"'), '\\"') // closing quote character .replaceAll(RegExp(r'\x08'), '\\b') // backspace .replaceAll(RegExp(r'\t'), '\\t') // horizontal tab .replaceAll(RegExp(r'\n'), '\\n') // line feed .replaceAll(RegExp(r'\f'), '\\f') // form feed .replaceAll(RegExp(r'\r'), '\\r') // carriage return - .replaceAllMapped(RegExp(r'[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]'), - (Match m) => Uri.encodeFull(m[0]!)) + - '"'; + .replaceAllMapped(RegExp(r'[\x00-\x07\x0B\x0E-\x1F\x80-\uFFFF]'), (Match m) => Uri.encodeFull(m[0]!))}"'; - dynamic parse(String? _input, String? _startRule) { - input = _input ?? ''; - startRule = _startRule; + dynamic parse(String? preInput, String? preStartRule) { + input = preInput ?? ''; + startRule = preStartRule; final parseFunctions = { 'fragment': _parseFragment, @@ -68,7 +64,7 @@ class EpubCfiParser { if (startRule != null) { if (parseFunctions[startRule!] == null) { - throw Exception('Invalid rule name: ' + quote(startRule!) + '.'); + throw Exception('Invalid rule name: ${quote(startRule!)}.'); } } else { startRule = 'fragment'; @@ -1660,9 +1656,7 @@ class CfiSyntaxException extends Equatable implements Exception { break; default: expectedHumanized = - expected.sublist(0, expected.length - 1).join(', ') + - ' or ' + - expected[expected.length - 1]; + '${expected.sublist(0, expected.length - 1).join(', ')} or ${expected[expected.length - 1]}'; } foundHumanized = diff --git a/packages/epub_view/lib/src/helpers/epub_document.dart b/packages/epub_view/lib/src/helpers/epub_document.dart index 9ad85513..b4746b8a 100644 --- a/packages/epub_view/lib/src/helpers/epub_document.dart +++ b/packages/epub_view/lib/src/helpers/epub_document.dart @@ -1,3 +1,4 @@ +// ignore: unnecessary_import import 'dart:typed_data'; import 'package:epubx/epubx.dart'; diff --git a/packages/epub_view/lib/src/ui/actual_chapter.dart b/packages/epub_view/lib/src/ui/actual_chapter.dart index dd3d7f11..1d072807 100644 --- a/packages/epub_view/lib/src/ui/actual_chapter.dart +++ b/packages/epub_view/lib/src/ui/actual_chapter.dart @@ -43,19 +43,19 @@ class EpubViewActualChapter extends StatelessWidget { switchOutCurve: Curves.easeOut, transitionBuilder: (Widget child, Animation animation) => SlideTransition( - child: FadeTransition(child: child, opacity: animation), position: Tween( begin: const Offset(0, -0.15), end: const Offset(0, 0), ).animate(animation), + child: FadeTransition(opacity: animation, child: child), ), layoutBuilder: (Widget? currentChild, List previousChildren) => Stack( + alignment: animationAlignment, children: [ ...previousChildren, if (currentChild != null) currentChild, ], - alignment: animationAlignment, ), child: content, ); diff --git a/packages/epub_view/lib/src/ui/epub_view.dart b/packages/epub_view/lib/src/ui/epub_view.dart index 74a93509..47190a4e 100644 --- a/packages/epub_view/lib/src/ui/epub_view.dart +++ b/packages/epub_view/lib/src/ui/epub_view.dart @@ -49,7 +49,7 @@ class EpubView extends StatefulWidget { final EpubViewBuilders builders; @override - _EpubViewState createState() => _EpubViewState(); + State createState() => _EpubViewState(); } class _EpubViewState extends State { diff --git a/packages/epub_view/lib/src/ui/table_of_contents.dart b/packages/epub_view/lib/src/ui/table_of_contents.dart index a03e177b..431ef861 100644 --- a/packages/epub_view/lib/src/ui/table_of_contents.dart +++ b/packages/epub_view/lib/src/ui/table_of_contents.dart @@ -52,7 +52,7 @@ class EpubViewTableOfContents extends StatelessWidget { return AnimatedSwitcher( duration: const Duration(milliseconds: 250), transitionBuilder: (Widget child, Animation animation) => - FadeTransition(child: child, opacity: animation), + FadeTransition(opacity: animation, child: child), child: content, ); }, diff --git a/packages/epub_view/test/generator_test.dart b/packages/epub_view/test/generator_test.dart index 5cc5a186..2b1af2c4 100644 --- a/packages/epub_view/test/generator_test.dart +++ b/packages/epub_view/test/generator_test.dart @@ -29,7 +29,7 @@ void main() { } catch (e) { expect( e.toString(), - FlutterError('A package document must be supplied to generate a CFI') + Exception('A package document must be supplied to generate a CFI') .toString(), ); } @@ -48,7 +48,7 @@ void main() { // when the id is not in the spine list expect( e.toString(), - FlutterError( + Exception( // ignore: lines_longer_than_80_chars 'The id ref of the content document could not be found in the spine') .toString(), @@ -79,7 +79,7 @@ void main() { } catch (e) { expect( e.toString(), - FlutterError('null: CFI target element is null').toString(), + Exception('null: CFI target element is null').toString(), ); } @@ -95,8 +95,7 @@ void main() { } catch (e) { expect( e.toString(), - FlutterError( - ': CFI target element is not an HTML element') + Exception(': CFI target element is not an HTML element') .toString(), ); } diff --git a/packages/epub_view/test/interpreter_test.dart b/packages/epub_view/test/interpreter_test.dart index b8987ed6..3954488b 100644 --- a/packages/epub_view/test/interpreter_test.dart +++ b/packages/epub_view/test/interpreter_test.dart @@ -36,7 +36,7 @@ void main() { } catch (e) { expect( e.toString(), - FlutterError('id3: id4 Id assertion failed').toString(), + Exception('id3: id4 Id assertion failed').toString(), ); } diff --git a/packages/explorer/analysis_options.yaml b/packages/explorer/analysis_options.yaml index f04c6cf0..dda045b5 100644 --- a/packages/explorer/analysis_options.yaml +++ b/packages/explorer/analysis_options.yaml @@ -1 +1,8 @@ -include: ../../analysis_options.yaml +include: package:flutter_lints/flutter.yaml + +analyzer: + exclude: + # Ignore generated files + - '**/*.g.dart' + - '**/generated_plugin_registrant.dart' + - '**/pigeon.dart' diff --git a/packages/explorer/example/android/app/build.gradle b/packages/explorer/example/android/app/build.gradle index f59248bc..964db2dc 100644 --- a/packages/explorer/example/android/app/build.gradle +++ b/packages/explorer/example/android/app/build.gradle @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 30 + compileSdkVersion 31 sourceSets { main.java.srcDirs += 'src/main/kotlin' @@ -36,7 +36,7 @@ android { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.example.explorer_example" minSdkVersion 16 - targetSdkVersion 30 + targetSdkVersion 31 versionCode flutterVersionCode.toInteger() versionName flutterVersionName } diff --git a/packages/explorer/example/android/app/src/main/AndroidManifest.xml b/packages/explorer/example/android/app/src/main/AndroidManifest.xml index d2beb637..3d35e239 100644 --- a/packages/explorer/example/android/app/src/main/AndroidManifest.xml +++ b/packages/explorer/example/android/app/src/main/AndroidManifest.xml @@ -1,41 +1,41 @@ - - - - - - - - - - - - - - - + + diff --git a/packages/explorer/lib/src/data/controller.dart b/packages/explorer/lib/src/data/controller.dart index ce2f0619..6cff058f 100644 --- a/packages/explorer/lib/src/data/controller.dart +++ b/packages/explorer/lib/src/data/controller.dart @@ -23,8 +23,8 @@ class ExplorerController { StreamController.broadcast(); Stream get actionStream => _actions.stream; - void _attach(_ExplorerState _explorerState) { - this._explorerState = _explorerState; + void _attach(_ExplorerState explorerState) { + _explorerState = explorerState; provider.go(provider.entryPath).then((entries) { if (_files.isClosed) { return; diff --git a/packages/explorer/lib/src/explorer.dart b/packages/explorer/lib/src/explorer.dart index 101c03f6..85c594c7 100644 --- a/packages/explorer/lib/src/explorer.dart +++ b/packages/explorer/lib/src/explorer.dart @@ -37,7 +37,7 @@ class Explorer extends StatefulWidget { final void Function(ExplorerFile)? filePressed; @override - _ExplorerState createState() => _ExplorerState(); + State createState() => _ExplorerState(); } class _ExplorerState extends State @@ -81,7 +81,7 @@ class _ExplorerState extends State onRefresh: widget.controller.refresh, child: CustomScrollView( controller: _scrollController, - physics: AlwaysScrollableScrollPhysics(), + physics: const AlwaysScrollableScrollPhysics(), slivers: widget.builder(context), ), ), diff --git a/packages/explorer/lib/src/i18n/localization.dart b/packages/explorer/lib/src/i18n/localization.dart index dd47bfc5..569a0a60 100644 --- a/packages/explorer/lib/src/i18n/localization.dart +++ b/packages/explorer/lib/src/i18n/localization.dart @@ -12,7 +12,7 @@ class ExplorerLocalizations with StringResources { : locale.toString(); final String canonicalLocaleName = Intl.canonicalizedLocale(localeName); Intl.defaultLocale = canonicalLocaleName; - print('canonicalLocaleName ' + canonicalLocaleName); + // print('canonicalLocaleName $canonicalLocaleName'); await initializeMessages(canonicalLocaleName); return ExplorerLocalizations(); } diff --git a/packages/explorer/lib/src/ui/provider.dart b/packages/explorer/lib/src/ui/provider.dart index 0a9c6ee0..7d06b1c6 100644 --- a/packages/explorer/lib/src/ui/provider.dart +++ b/packages/explorer/lib/src/ui/provider.dart @@ -16,9 +16,9 @@ class ControllerProvider extends InheritedWidget { final ScrollController? scrollController; @override - bool updateShouldNotify(ControllerProvider old) => - explorerController != old.explorerController || - scrollController != old.scrollController; + bool updateShouldNotify(ControllerProvider oldWidget) => + explorerController != oldWidget.explorerController || + scrollController != oldWidget.scrollController; static ControllerProvider? of(BuildContext context) => context.findAncestorWidgetOfExactType(); diff --git a/packages/explorer/lib/src/ui/widgets/action.dart b/packages/explorer/lib/src/ui/widgets/action.dart index 17d3968a..59363ffa 100644 --- a/packages/explorer/lib/src/ui/widgets/action.dart +++ b/packages/explorer/lib/src/ui/widgets/action.dart @@ -8,8 +8,10 @@ import 'package:flutter/material.dart'; /// Available actions view for explorer builder class ExplorerActionView extends StatefulWidget { + const ExplorerActionView({Key? key}) : super(key: key); + @override - _ExplorerActionViewState createState() => _ExplorerActionViewState(); + State createState() => _ExplorerActionViewState(); } class _ExplorerActionViewState extends State @@ -24,7 +26,7 @@ class _ExplorerActionViewState extends State _animationController = AnimationController( vsync: this, - duration: Duration(milliseconds: 300), + duration: const Duration(milliseconds: 300), ); _subscription = _controller.actionStream.listen((state) { @@ -54,7 +56,7 @@ class _ExplorerActionViewState extends State initialData: ExplorerActionEmpty(), stream: _controller.actionStream, builder: (_, snapshot) { - Widget content = SizedBox(); + Widget content = const SizedBox(); if (snapshot.data is ExplorerActionCopy || snapshot.data is ExplorerActionMove) { content = Container( @@ -82,12 +84,12 @@ class _ExplorerActionViewState extends State ); }, ), - SizedBox(width: 16), - VerticalDivider(indent: 8, endIndent: 8), - SizedBox(width: 16), + const SizedBox(width: 16), + const VerticalDivider(indent: 8, endIndent: 8), + const SizedBox(width: 16), TextButton( - child: Text(i18n!.cancel), onPressed: _controller.cancelAction, + child: Text(i18n!.cancel), ), ], ), @@ -97,8 +99,8 @@ class _ExplorerActionViewState extends State return SliverToBoxAdapter( child: SlideTransition( position: Tween( - begin: Offset(0, -1), - end: Offset(0, 0), + begin: const Offset(0, -1), + end: const Offset(0, 0), ).animate(_animationController), child: content, ), diff --git a/packages/explorer/lib/src/ui/widgets/breadcrumbs.dart b/packages/explorer/lib/src/ui/widgets/breadcrumbs.dart index 4103afa6..d905c93a 100644 --- a/packages/explorer/lib/src/ui/widgets/breadcrumbs.dart +++ b/packages/explorer/lib/src/ui/widgets/breadcrumbs.dart @@ -8,8 +8,10 @@ import 'package:flutter_breadcrumb/flutter_breadcrumb.dart'; /// Location (path) breadcrumbs view for explorer builder class ExplorerBreadCrumbs extends StatefulWidget { + const ExplorerBreadCrumbs({Key? key}) : super(key: key); + @override - _ExplorerBreadCrumbsState createState() => _ExplorerBreadCrumbsState(); + State createState() => _ExplorerBreadCrumbsState(); } class _ExplorerBreadCrumbsState extends State @@ -26,7 +28,7 @@ class _ExplorerBreadCrumbsState extends State _animationController = AnimationController( vsync: this, - duration: Duration(milliseconds: 300), + duration: const Duration(milliseconds: 300), ); _subscription = _controller.stream.listen((state) { @@ -67,19 +69,18 @@ class _ExplorerBreadCrumbsState extends State } }); - return Container( - child: BreadCrumb( - overflow: ScrollableOverflow(controller: _scrollController), - items: [ - for (final crumb in _controller.breadCrumbs) - BreadCrumbItem( - padding: EdgeInsets.symmetric(horizontal: 8, vertical: 12), - content: Text(crumb.name, style: theme.textTheme.bodyText1), - onTap: () => _controller.go(crumb.path), - ), - ], - divider: Icon(Icons.chevron_right), - ), + return BreadCrumb( + overflow: ScrollableOverflow(controller: _scrollController), + items: [ + for (final crumb in _controller.breadCrumbs) + BreadCrumbItem( + padding: + const EdgeInsets.symmetric(horizontal: 8, vertical: 12), + content: Text(crumb.name, style: theme.textTheme.bodyText1), + onTap: () => _controller.go(crumb.path), + ), + ], + divider: const Icon(Icons.chevron_right), ); }, ); diff --git a/packages/explorer/lib/src/ui/widgets/entry.dart b/packages/explorer/lib/src/ui/widgets/entry.dart index a24b3f71..38b00a1d 100644 --- a/packages/explorer/lib/src/ui/widgets/entry.dart +++ b/packages/explorer/lib/src/ui/widgets/entry.dart @@ -5,7 +5,7 @@ import 'package:flutter/material.dart'; /// Entry view class EntryExplorer extends StatefulWidget { - EntryExplorer({ + const EntryExplorer({ required this.entry, this.onPressed, this.onLongPress, @@ -22,7 +22,7 @@ class EntryExplorer extends StatefulWidget { final void Function(RelativeRect position)? onLongPress; @override - _EntryExplorerState createState() => _EntryExplorerState(); + State createState() => _EntryExplorerState(); } class _EntryExplorerState extends State { @@ -31,6 +31,43 @@ class _EntryExplorerState extends State { @override Widget build(BuildContext context) => Listener( child: InkWell( + // child: Flex( + // direction: Axis.vertical, + // // mainAxisAlignment: MainAxisAlignment.center, + // // crossAxisAlignment: CrossAxisAlignment.center, + // children: [ + // Flexible( + // flex: 2, + // child: Icon( + // iconByEntry(widget.entry), + // size: 48, + // ), + // ), + // SizedBox(height: 8), + // Flexible( + // flex: 1, + // child: Text( + // widget.entry.name, + // textAlign: TextAlign.center, + // ), + // ), + // ], + // ), + onTap: widget.onPressed, + onLongPress: () { + final RenderBox overlay = + Overlay.of(context)!.context.findRenderObject() as RenderBox; + + widget.onLongPress!(RelativeRect.fromLTRB( + _tapDownPosition.dx, + _tapDownPosition.dy, + overlay.size.width - _tapDownPosition.dx, + overlay.size.height - _tapDownPosition.dy, + )); + }, + onTapDown: (TapDownDetails details) { + _tapDownPosition = details.globalPosition; + }, // child: Flex( // direction: Axis.vertical, // // mainAxisAlignment: MainAxisAlignment.center, @@ -86,21 +123,6 @@ class _EntryExplorerState extends State { ); }, ), - onTap: widget.onPressed, - onLongPress: () { - final RenderBox overlay = - Overlay.of(context)!.context.findRenderObject() as RenderBox; - - widget.onLongPress!(RelativeRect.fromLTRB( - _tapDownPosition.dx, - _tapDownPosition.dy, - overlay.size.width - _tapDownPosition.dx, - overlay.size.height - _tapDownPosition.dy, - )); - }, - onTapDown: (TapDownDetails details) { - _tapDownPosition = details.globalPosition; - }, ), onPointerDown: (PointerDownEvent event) { if (!(event.kind == PointerDeviceKind.mouse && @@ -117,7 +139,6 @@ class _EntryExplorerState extends State { overlay.size.width - event.position.dx, overlay.size.height - event.position.dy, )); - print('!!!! RB clicked'); }, ); } diff --git a/packages/explorer/lib/src/ui/widgets/grid.dart b/packages/explorer/lib/src/ui/widgets/grid.dart index 7500dfff..50533c62 100644 --- a/packages/explorer/lib/src/ui/widgets/grid.dart +++ b/packages/explorer/lib/src/ui/widgets/grid.dart @@ -10,8 +10,10 @@ import 'package:sliver_tools/sliver_tools.dart'; import 'entry.dart'; class ExplorerFilesGridView extends StatefulWidget { + const ExplorerFilesGridView({Key? key}) : super(key: key); + @override - _ExplorerFilesGridViewState createState() => _ExplorerFilesGridViewState(); + State createState() => _ExplorerFilesGridViewState(); } class _ExplorerFilesGridViewState extends State { @@ -43,41 +45,41 @@ class _ExplorerFilesGridViewState extends State { value: 'open', child: Row( children: [ - Icon(Icons.launch), - SizedBox(width: 16), + const Icon(Icons.launch), + const SizedBox(width: 16), Text(i18n.actionMenuOpen), ], ), ), - PopupMenuDivider(), + const PopupMenuDivider(), PopupMenuItem( value: 'copy', child: Row( children: [ - Icon(Icons.content_copy), - SizedBox(width: 16), + const Icon(Icons.content_copy), + const SizedBox(width: 16), Text(i18n.actionMenuCopy), ], ), ), - PopupMenuDivider(), + const PopupMenuDivider(), PopupMenuItem( value: 'cut', child: Row( children: [ - Icon(Icons.content_cut), - SizedBox(width: 16), + const Icon(Icons.content_cut), + const SizedBox(width: 16), Text(i18n.actionMenuCut), ], ), ), - PopupMenuDivider(), + const PopupMenuDivider(), PopupMenuItem( value: 'delete', child: Row( children: [ - Icon(Icons.delete), - SizedBox(width: 16), + const Icon(Icons.delete), + const SizedBox(width: 16), Text(i18n.actionMenuDelete), ], ), @@ -125,8 +127,8 @@ class _ExplorerFilesGridViewState extends State { ), LiveSliverGrid( controller: ControllerProvider.of(context)!.scrollController!, - showItemInterval: Duration(milliseconds: 25), - showItemDuration: Duration(milliseconds: 125), + showItemInterval: const Duration(milliseconds: 25), + showItemDuration: const Duration(milliseconds: 125), itemCount: entries.length, itemBuilder: (BuildContext context, int index, animation) { final entry = entries[index]; @@ -138,7 +140,7 @@ class _ExplorerFilesGridViewState extends State { ).animate(animation), child: SlideTransition( position: Tween( - begin: Offset(0, -0.025), + begin: const Offset(0, -0.025), end: Offset.zero, ).animate(animation), child: EntryExplorer( diff --git a/packages/explorer/lib/src/ui/widgets/toolbar.dart b/packages/explorer/lib/src/ui/widgets/toolbar.dart index 23ad5737..8aa6f286 100644 --- a/packages/explorer/lib/src/ui/widgets/toolbar.dart +++ b/packages/explorer/lib/src/ui/widgets/toolbar.dart @@ -60,7 +60,7 @@ class ExplorerToolbar extends StatelessWidget { @override Widget build(BuildContext context) { - final _controller = ControllerProvider.of(context)!.explorerController; + final controller = ControllerProvider.of(context)!.explorerController; final i18n = ExplorerLocalizations.of(context); final safeTopPadding = MediaQuery.of(context).padding.top; @@ -71,26 +71,26 @@ class ExplorerToolbar extends StatelessWidget { mainAxisSize: MainAxisSize.max, mainAxisAlignment: MainAxisAlignment.spaceBetween, children: [ - Expanded(child: ExplorerBreadCrumbs()), - VerticalDivider(indent: 8, endIndent: 8), + const Expanded(child: ExplorerBreadCrumbs()), + const VerticalDivider(indent: 8, endIndent: 8), Row( children: [ IconButton( - icon: Icon(Icons.refresh), - onPressed: _controller.refresh, + icon: const Icon(Icons.refresh), + onPressed: controller.refresh, ), PopupMenuButton( - icon: Icon(Icons.add), + icon: const Icon(Icons.add), onSelected: (String value) async { if (value == 'directory') { final folderName = await openModal(context, i18n!.folderName); - _controller.newDirectory(folderName!); + controller.newDirectory(folderName!); } else if (value == 'file') { final fileName = await openModal(context, i18n!.fileName); - _controller.newFile(fileName!); + controller.newFile(fileName!); } else if (value == 'upload') { - _controller.uploadLocalFiles(); + controller.uploadLocalFiles(); } }, tooltip: 'Add', @@ -99,34 +99,34 @@ class ExplorerToolbar extends StatelessWidget { value: 'directory', child: Row( children: [ - Icon(Icons.create_new_folder), - SizedBox(width: 16), + const Icon(Icons.create_new_folder), + const SizedBox(width: 16), Text(i18n!.newFolder), ], ), ), - PopupMenuDivider(), + const PopupMenuDivider(), PopupMenuItem( value: 'file', child: Row( children: [ - Icon(Icons.note_add), - SizedBox(width: 16), + const Icon(Icons.note_add), + const SizedBox(width: 16), Text(i18n.newFile), ], ), ), - PopupMenuDivider(), + const PopupMenuDivider(), PopupMenuItem( value: 'upload', + enabled: controller.hasUploadFilesCallback, child: Row( children: [ - Icon(Icons.upload_file), - SizedBox(width: 16), + const Icon(Icons.upload_file), + const SizedBox(width: 16), Text(i18n.uploadFiles), ], ), - enabled: _controller.hasUploadFilesCallback, ), ], ), diff --git a/packages/explorer/pubspec.yaml b/packages/explorer/pubspec.yaml index e1bfc83c..462e6a07 100644 --- a/packages/explorer/pubspec.yaml +++ b/packages/explorer/pubspec.yaml @@ -25,6 +25,7 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter + flutter_lints: ^2.0.1 # intl_translation: ^0.17.10+1 # dependency_overrides: diff --git a/packages/flutter_color/analysis_options.yaml b/packages/flutter_color/analysis_options.yaml deleted file mode 100644 index f04c6cf0..00000000 --- a/packages/flutter_color/analysis_options.yaml +++ /dev/null @@ -1 +0,0 @@ -include: ../../analysis_options.yaml diff --git a/packages/flutter_color/example/android/app/build.gradle b/packages/flutter_color/example/android/app/build.gradle index c05bc46e..6426420d 100644 --- a/packages/flutter_color/example/android/app/build.gradle +++ b/packages/flutter_color/example/android/app/build.gradle @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 29 + compileSdkVersion 31 sourceSets { main.java.srcDirs += 'src/main/kotlin' @@ -40,7 +40,7 @@ android { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "io.scer.flutter_color_example" minSdkVersion 16 - targetSdkVersion 29 + targetSdkVersion 31 versionCode flutterVersionCode.toInteger() versionName flutterVersionName } diff --git a/packages/flutter_color/example/android/app/src/main/AndroidManifest.xml b/packages/flutter_color/example/android/app/src/main/AndroidManifest.xml index 75c540b9..3d5eb427 100644 --- a/packages/flutter_color/example/android/app/src/main/AndroidManifest.xml +++ b/packages/flutter_color/example/android/app/src/main/AndroidManifest.xml @@ -1,47 +1,46 @@ - - - - - - - - - - - - - - - - + + diff --git a/packages/flutter_color/example/ios/Runner.xcodeproj/project.pbxproj b/packages/flutter_color/example/ios/Runner.xcodeproj/project.pbxproj index ee0244b2..f59c541c 100644 --- a/packages/flutter_color/example/ios/Runner.xcodeproj/project.pbxproj +++ b/packages/flutter_color/example/ios/Runner.xcodeproj/project.pbxproj @@ -3,7 +3,7 @@ archiveVersion = 1; classes = { }; - objectVersion = 46; + objectVersion = 50; objects = { /* Begin PBXBuildFile section */ @@ -288,13 +288,17 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = 7D294NMXAJ; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", ); INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", @@ -407,7 +411,8 @@ MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SUPPORTED_PLATFORMS = iphoneos; - SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; + SWIFT_COMPILATION_MODE = wholemodule; + SWIFT_OPTIMIZATION_LEVEL = "-O"; TARGETED_DEVICE_FAMILY = "1,2"; VALIDATE_PRODUCT = YES; }; @@ -420,13 +425,17 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = 7D294NMXAJ; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", ); INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", @@ -447,13 +456,17 @@ ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon; CLANG_ENABLE_MODULES = YES; CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)"; + DEVELOPMENT_TEAM = 7D294NMXAJ; ENABLE_BITCODE = NO; FRAMEWORK_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", ); INFOPLIST_FILE = Runner/Info.plist; - LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks"; + LD_RUNPATH_SEARCH_PATHS = ( + "$(inherited)", + "@executable_path/Frameworks", + ); LIBRARY_SEARCH_PATHS = ( "$(inherited)", "$(PROJECT_DIR)/Flutter", diff --git a/packages/flutter_color/lib/src/helper.dart b/packages/flutter_color/lib/src/helper.dart index 1af1d8d6..f7ac7b66 100644 --- a/packages/flutter_color/lib/src/helper.dart +++ b/packages/flutter_color/lib/src/helper.dart @@ -64,5 +64,5 @@ extension ColorHelper on Color { Color? mix(Color another, double amount) => Color.lerp(this, another, amount); /// Convert color to hex string - String get asHexString => '#' + value.toRadixString(16).toUpperCase(); + String get asHexString => '#${value.toRadixString(16).toUpperCase()}'; } diff --git a/packages/flutter_color/lib/src/hex.dart b/packages/flutter_color/lib/src/hex.dart index 2659f521..ddd8540d 100644 --- a/packages/flutter_color/lib/src/hex.dart +++ b/packages/flutter_color/lib/src/hex.dart @@ -14,7 +14,7 @@ class HexColor extends Color { static int getColorFromHex(String hex) { String hexColor = hex.toUpperCase().replaceAll('#', ''); if (hexColor.length == 6) { - hexColor = 'FF' + hexColor; + hexColor = 'FF$hexColor'; } return int.parse(hexColor, radix: 16); } diff --git a/packages/flutter_color/pubspec.yaml b/packages/flutter_color/pubspec.yaml index 9c459cf8..25264307 100644 --- a/packages/flutter_color/pubspec.yaml +++ b/packages/flutter_color/pubspec.yaml @@ -15,4 +15,4 @@ dependencies: dev_dependencies: flutter_test: sdk: flutter - pedantic: ^1.11.0 + flutter_lints: ^2.0.1 diff --git a/packages/flutter_color/test/flutter_color_test.dart b/packages/flutter_color/test/flutter_color_test.dart new file mode 100644 index 00000000..6cda6454 --- /dev/null +++ b/packages/flutter_color/test/flutter_color_test.dart @@ -0,0 +1,53 @@ +import 'package:flutter/painting.dart'; +import 'package:flutter_color/flutter_color.dart'; +import 'package:flutter_test/flutter_test.dart'; + +void main() { + TestWidgetsFlutterBinding.ensureInitialized(); + group('hex color', () { + test('Normal color', () { + expect(HexColor('#FFFFFF').value, equals(const Color(0xFFFFFFFF).value)); + expect(HexColor('FFFFFF').value, equals(const Color(0xFFFFFFFF).value)); + }); + test('Color with transparent', () { + expect( + HexColor('#B1FFFFFF').value, equals(const Color(0xB1FFFFFF).value)); + expect( + HexColor('#00FFFFFF').value, equals(const Color(0x00FFFFFF).value)); + expect(HexColor('00FFFFFF').value, equals(const Color(0x00FFFFFF).value)); + }); + }); + + group('Helpers', () { + test('conversation', () { + expect(const Color.fromRGBO(255, 255, 255, 1).asHexString, '#FFFFFFFF'); + }); + + test('lighter', () { + expect(const Color(0xFF000000).lighter(100), const Color(0xFFFFFFFF)); + expect( + const Color.fromARGB(255, 64, 64, 64).lighter(50), + const Color.fromARGB(255, 192, 192, 192), + ); + }); + + test('darker', () { + expect(const Color(0xFFFFFFFF).darker(100), const Color(0xFF000000)); + expect( + const Color.fromARGB(255, 192, 192, 192).darker(25), + const Color.fromARGB(255, 128, 128, 128), + ); + }); + + test('mix', () { + expect(const Color(0xFFFFFFFF).mix(const Color(0xFF000000), 1), + const Color(0xFF000000)); + expect(const Color(0xFFFFFFFF).mix(const Color(0xFF000000), .5), + const Color(0xFF7F7F7F)); + expect(const Color(0xFFB5A642).mix(const Color(0xFF6C541E), .37), + const Color(0xFF998734)); + expect(const Color(0xFFFF0000).mix(const Color(0xFF00FF00), .25), + const Color(0xFFBF3F00)); + }); + }); +} diff --git a/packages/flutter_color/test/native_color_test.dart b/packages/flutter_color/test/native_color_test.dart deleted file mode 100644 index aa4f40bc..00000000 --- a/packages/flutter_color/test/native_color_test.dart +++ /dev/null @@ -1,47 +0,0 @@ -import 'package:flutter/painting.dart'; -import 'package:flutter_color/flutter_color.dart'; -import 'package:flutter_test/flutter_test.dart'; - -void main() { - TestWidgetsFlutterBinding.ensureInitialized(); - group('hex color', () { - test('Normal color', () { - expect(HexColor('#FFFFFF').value, equals(Color(0xFFFFFFFF).value)); - expect(HexColor('FFFFFF').value, equals(Color(0xFFFFFFFF).value)); - }); - test('Color with transparent', () { - expect(HexColor('#B1FFFFFF').value, equals(Color(0xB1FFFFFF).value)); - expect(HexColor('#00FFFFFF').value, equals(Color(0x00FFFFFF).value)); - expect(HexColor('00FFFFFF').value, equals(Color(0x00FFFFFF).value)); - }); - }); - - group('Helpers', () { - test('conversation', () { - expect(Color.fromRGBO(255, 255, 255, 1).asHexString, '#FFFFFFFF'); - }); - - test('lighter', () { - expect(Color(0xFF000000).lighter(100), Color(0xFFFFFFFF)); - expect( - Color.fromARGB(255, 64, 64, 64).lighter(50), - Color.fromARGB(255, 192, 192, 192), - ); - }); - - test('darker', () { - expect(Color(0xFFFFFFFF).darker(100), Color(0xFF000000)); - expect( - Color.fromARGB(255, 192, 192, 192).darker(25), - Color.fromARGB(255, 128, 128, 128), - ); - }); - - test('mix', () { - expect(Color(0xFFFFFFFF).mix(Color(0xFF000000), 1), Color(0xFF000000)); - expect(Color(0xFFFFFFFF).mix(Color(0xFF000000), .5), Color(0xFF7F7F7F)); - expect(Color(0xFFB5A642).mix(Color(0xFF6C541E), .37), Color(0xFF998734)); - expect(Color(0xFFFF0000).mix(Color(0xFF00FF00), .25), Color(0xFFBF3F00)); - }); - }); -} diff --git a/packages/pdfx/analysis_options.yaml b/packages/pdfx/analysis_options.yaml index 8e4c4f55..7a647278 100644 --- a/packages/pdfx/analysis_options.yaml +++ b/packages/pdfx/analysis_options.yaml @@ -1 +1,8 @@ include: package:flutter_lints/flutter.yaml + +analyzer: + exclude: + # Ignore generated files + - '**/*.g.dart' + - '**/generated_plugin_registrant.dart' + - '**/pigeon.dart' diff --git a/packages/pdfx/android/build.gradle b/packages/pdfx/android/build.gradle index 461587fd..2223dd45 100644 --- a/packages/pdfx/android/build.gradle +++ b/packages/pdfx/android/build.gradle @@ -25,11 +25,12 @@ apply plugin: 'com.android.library' apply plugin: 'kotlin-android' android { - compileSdkVersion 30 + compileSdkVersion 31 sourceSets { main.java.srcDirs += 'src/main/kotlin' } + defaultConfig { minSdkVersion 16 } diff --git a/packages/pdfx/bin/install_windows.dart b/packages/pdfx/bin/install_windows.dart index dffaa539..484bc140 100644 --- a/packages/pdfx/bin/install_windows.dart +++ b/packages/pdfx/bin/install_windows.dart @@ -19,7 +19,7 @@ void main(List args) async { exit(2); } - await cMakeFile.writeAsString(document + '\n\n' + _template); + await cMakeFile.writeAsString('$document\n\n$_template'); stdout.writeln('installation successfully'); } diff --git a/packages/pdfx/example/android/app/build.gradle b/packages/pdfx/example/android/app/build.gradle index d060b13f..2fe2eb77 100644 --- a/packages/pdfx/example/android/app/build.gradle +++ b/packages/pdfx/example/android/app/build.gradle @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 32 + compileSdkVersion 31 sourceSets { main.java.srcDirs += 'src/main/kotlin' @@ -35,7 +35,7 @@ android { defaultConfig { applicationId "io.scer.pdfx_example" minSdkVersion 16 - targetSdkVersion 32 + targetSdkVersion 31 versionCode flutterVersionCode.toInteger() versionName flutterVersionName } diff --git a/packages/pdfx/ios/Classes/SwiftPdfxPlugin.swift b/packages/pdfx/ios/Classes/SwiftPdfxPlugin.swift index 0e1c103b..8609e444 100644 --- a/packages/pdfx/ios/Classes/SwiftPdfxPlugin.swift +++ b/packages/pdfx/ios/Classes/SwiftPdfxPlugin.swift @@ -30,8 +30,8 @@ public class SwiftPdfxPlugin: NSObject, FlutterPlugin, PdfxApi { PdfxApiSetup(messenger, api); } - public func openDocumentDataMessage(_ message: OpenDataMessage?, completion: @escaping (OpenReply?, FlutterError?) -> Void) { - guard let data = message?.data else { + public func openDocumentDataMessage(_ message: OpenDataMessage, completion: @escaping (OpenReply?, FlutterError?) -> Void) { + guard let data = message.data else { return completion(nil, FlutterError(code: "RENDER_ERROR", message: "Arguments not sended", details: nil)) @@ -50,8 +50,8 @@ public class SwiftPdfxPlugin: NSObject, FlutterPlugin, PdfxApi { completion(result, nil); } - public func openDocumentFileMessage(_ message: OpenPathMessage?, completion: @escaping (OpenReply?, FlutterError?) -> Void) { - guard let pdfFilePath = message?.path else { + public func openDocumentFileMessage(_ message: OpenPathMessage, completion: @escaping (OpenReply?, FlutterError?) -> Void) { + guard let pdfFilePath = message.path else { return completion(nil, FlutterError(code: "RENDER_ERROR", message: "Arguments not sended", details: nil)) @@ -70,8 +70,8 @@ public class SwiftPdfxPlugin: NSObject, FlutterPlugin, PdfxApi { completion(result, nil); } - public func openDocumentAssetMessage(_ message: OpenPathMessage?, completion: @escaping (OpenReply?, FlutterError?) -> Void) { - guard let name = message?.path else { + public func openDocumentAssetMessage(_ message: OpenPathMessage, completion: @escaping (OpenReply?, FlutterError?) -> Void) { + guard let name = message.path else { return completion(nil, FlutterError(code: "RENDER_ERROR", message: "Arguments not sended", details: nil)) @@ -96,10 +96,10 @@ public class SwiftPdfxPlugin: NSObject, FlutterPlugin, PdfxApi { } } - public func getPageMessage(_ message: GetPageMessage?, completion: @escaping (GetPageReply?, FlutterError?) -> Void) { + public func getPageMessage(_ message: GetPageMessage, completion: @escaping (GetPageReply?, FlutterError?) -> Void) { do { - let documentId = message!.documentId - let pageNumber = message!.pageNumber + let documentId = message.documentId + let pageNumber = message.pageNumber let result = GetPageReply.init(); @@ -122,15 +122,15 @@ public class SwiftPdfxPlugin: NSObject, FlutterPlugin, PdfxApi { } } - public func renderPageMessage(_ message: RenderPageMessage?, completion: @escaping (RenderPageReply?, FlutterError?) -> Void) { + public func renderPageMessage(_ message: RenderPageMessage, completion: @escaping (RenderPageReply?, FlutterError?) -> Void) { // Set crop if required var cropZone: CGRect? = nil - if (message!.crop!.boolValue){ - let cWidth = message!.cropWidth!.intValue - let cHeight = message!.cropHeight!.intValue - if (cWidth != message!.width!.intValue || cHeight != message!.height!.intValue){ - cropZone = CGRect(x: message!.cropX as! Int, - y: message!.cropY as! Int, + if (message.crop!.boolValue){ + let cWidth = message.cropWidth!.intValue + let cHeight = message.cropHeight!.intValue + if (cWidth != message.width!.intValue || cHeight != message.height!.intValue){ + cropZone = CGRect(x: message.cropX as! Int, + y: message.cropY as! Int, width: cWidth, height: cHeight) } @@ -139,14 +139,14 @@ public class SwiftPdfxPlugin: NSObject, FlutterPlugin, PdfxApi { dispQueue.async { let result = RenderPageReply.init() do { - let page = try self.pages.get(id: message!.pageId!) + let page = try self.pages.get(id: message.pageId!) if let data = page.render( - width: message!.width!.intValue, - height: message!.height!.intValue, + width: message.width!.intValue, + height: message.height!.intValue, crop: cropZone, - compressFormat: CompressFormat(rawValue: message!.format!.intValue)!, - backgroundColor: message!.backgroundColor!, - quality: message!.quality!.intValue + compressFormat: CompressFormat(rawValue: message.format!.intValue)!, + backgroundColor: message.backgroundColor!, + quality: message.quality!.intValue ) { result.width = NSNumber.init(value: data.width) result.height = NSNumber.init(value: data.height) @@ -193,35 +193,35 @@ public class SwiftPdfxPlugin: NSObject, FlutterPlugin, PdfxApi { textures[texId!] = nil } - public func resizeTextureMessage(_ message: ResizeTextureMessage?, completion: @escaping (FlutterError?) -> Void) { - let texId = message!.textureId?.int64Value + public func resizeTextureMessage(_ message: ResizeTextureMessage, completion: @escaping (FlutterError?) -> Void) { + let texId = message.textureId?.int64Value guard let pageTex = textures[texId!] else { return completion(FlutterError(code: "RENDER_ERROR", message: "No texture of texId=\(String(describing: texId!))", details: nil)) } - let width = message!.width?.intValue, - height = message!.height?.intValue + let width = message.width?.intValue, + height = message.height?.intValue pageTex.resize(width: width!, height: height!) return completion(nil) } - public func updateTextureMessage(_ message: UpdateTextureMessage?, completion: @escaping (FlutterError?) -> Void) { - let texId = message!.textureId?.int64Value - let pageId = message!.pageId! - let destX = message?.destinationX?.intValue - let destY = message?.destinationY?.intValue - let width = message?.width?.intValue - let height = message?.height?.intValue - let srcX = message?.sourceX?.intValue - let srcY = message?.sourceY?.intValue - let fw = message?.fullWidth?.doubleValue - let fh = message?.fullHeight?.doubleValue - let backgroundColor = message?.backgroundColor - let allowAntialiasing = message!.allowAntiAliasing?.boolValue - - let tw = message?.textureWidth?.intValue - let th = message?.textureHeight?.intValue + public func updateTextureMessage(_ message: UpdateTextureMessage, completion: @escaping (FlutterError?) -> Void) { + let texId = message.textureId?.int64Value + let pageId = message.pageId! + let destX = message.destinationX?.intValue + let destY = message.destinationY?.intValue + let width = message.width?.intValue + let height = message.height?.intValue + let srcX = message.sourceX?.intValue + let srcY = message.sourceY?.intValue + let fw = message.fullWidth?.doubleValue + let fh = message.fullHeight?.doubleValue + let backgroundColor = message.backgroundColor + let allowAntialiasing = message.allowAntiAliasing?.boolValue + + let tw = message.textureWidth?.intValue + let th = message.textureHeight?.intValue let pageTex = textures[texId!]! diff --git a/packages/pdfx/lib/src/renderer/io/platform_method_channel.dart b/packages/pdfx/lib/src/renderer/io/platform_method_channel.dart index 736f743e..bbeb878d 100644 --- a/packages/pdfx/lib/src/renderer/io/platform_method_channel.dart +++ b/packages/pdfx/lib/src/renderer/io/platform_method_channel.dart @@ -1,6 +1,8 @@ import 'dart:async'; +// ignore: unnecessary_import import 'dart:typed_data'; +// ignore: unnecessary_import import 'package:flutter/painting.dart'; import 'package:flutter/services.dart'; import 'package:meta/meta.dart'; diff --git a/packages/pdfx/lib/src/renderer/web/platform.dart b/packages/pdfx/lib/src/renderer/web/platform.dart index 57c0630a..4176c887 100644 --- a/packages/pdfx/lib/src/renderer/web/platform.dart +++ b/packages/pdfx/lib/src/renderer/web/platform.dart @@ -1,8 +1,10 @@ import 'dart:async'; import 'dart:html' as html; import 'dart:js' as js; +// ignore: unnecessary_import import 'dart:typed_data'; +// ignore: unnecessary_import import 'package:flutter/painting.dart'; import 'package:flutter/services.dart'; import 'package:flutter_web_plugins/flutter_web_plugins.dart'; @@ -226,14 +228,14 @@ class PdfPageImageWeb extends PdfPageImage { required bool removeTempFile, required PdfjsPage pdfJsPage, }) async { - final _viewport = pdfJsPage.getViewport(PdfjsViewportParams(scale: 1)); + final preViewport = pdfJsPage.getViewport(PdfjsViewportParams(scale: 1)); final html.CanvasElement canvas = js.context['document'].createElement('canvas'); final html.CanvasRenderingContext2D context = canvas.getContext('2d') as html.CanvasRenderingContext2D; final viewport = pdfJsPage - .getViewport(PdfjsViewportParams(scale: width / _viewport.width)); + .getViewport(PdfjsViewportParams(scale: width / preViewport.width)); canvas ..height = viewport.height.toInt() @@ -402,11 +404,14 @@ class PdfPageTextureWeb extends PdfPageTexture { final vp1 = page.renderer.getViewport(PdfjsViewportParams(scale: 1)); final pw = vp1.width; //final ph = vp1.height; - final _fullWidth = fullWidth ?? pw; + final preFullWidth = fullWidth ?? pw; //final fullHeight = args['fullHeight'] as double? ?? ph; - final _width = width; - final _height = height; - if (_width == null || _height == null || _width <= 0 || _height <= 0) { + final preWidth = width; + final preHeight = height; + if (preWidth == null || + preHeight == null || + preWidth <= 0 || + preHeight <= 0) { return false; } @@ -414,15 +419,15 @@ class PdfPageTextureWeb extends PdfPageTexture { final offsetY = -sourceY.toDouble(); final vp = page.renderer.getViewport(PdfjsViewportParams( - scale: _fullWidth / pw, + scale: preFullWidth / pw, offsetX: offsetX, offsetY: offsetY, dontFlip: dontFlip, )); final canvas = (html.document.createElement('canvas') as html.CanvasElement) - ..width = _width - ..height = _height; + ..width = preWidth + ..height = preHeight; final html.CanvasRenderingContext2D context = canvas.getContext('2d') as html.CanvasRenderingContext2D; @@ -430,7 +435,7 @@ class PdfPageTextureWeb extends PdfPageTexture { if (backgroundColor != null) { context ..fillStyle = backgroundColor - ..fillRect(0, 0, _width, _height); + ..fillRect(0, 0, preWidth, preHeight); } final rendererContext = PdfjsRenderContext( @@ -453,7 +458,7 @@ class PdfPageTextureWeb extends PdfPageTexture { }); await completer.future; - return handleRawData(data, _width, _height); + return handleRawData(data, preWidth, preHeight); } } diff --git a/packages/pdfx/lib/src/viewer/pdf_page_image_provider.dart b/packages/pdfx/lib/src/viewer/pdf_page_image_provider.dart index 3b11176d..2880c919 100644 --- a/packages/pdfx/lib/src/viewer/pdf_page_image_provider.dart +++ b/packages/pdfx/lib/src/viewer/pdf_page_image_provider.dart @@ -1,3 +1,4 @@ +// ignore: unnecessary_import import 'dart:typed_data'; import 'dart:ui' as ui show Codec; import 'package:flutter/foundation.dart'; @@ -19,6 +20,7 @@ class PdfPageImageProvider extends ImageProvider { final double scale; @override + // ignore: deprecated_member_use ImageStreamCompleter load(PdfPageImageProvider key, DecoderCallback decode) => MultiFrameImageStreamCompleter( codec: _loadAsync(key, decode), @@ -33,7 +35,9 @@ class PdfPageImageProvider extends ImageProvider { SynchronousFuture(this); Future _loadAsync( - PdfPageImageProvider key, DecoderCallback decode) async { + PdfPageImageProvider key, + // ignore: deprecated_member_use + DecoderCallback decode) async { assert(key == this); final loadedPdfPageImage = await pdfPageImage; @@ -62,5 +66,5 @@ class PdfPageImageProvider extends ImageProvider { } @override - int get hashCode => hashValues(pageNumber, documentId, scale); + int get hashCode => Object.hash(pageNumber, documentId, scale); } diff --git a/packages/pdfx/lib/src/viewer/pinch/pdf_view_pinch.dart b/packages/pdfx/lib/src/viewer/pinch/pdf_view_pinch.dart index 11d42a8e..97683437 100644 --- a/packages/pdfx/lib/src/viewer/pinch/pdf_view_pinch.dart +++ b/packages/pdfx/lib/src/viewer/pinch/pdf_view_pinch.dart @@ -62,7 +62,7 @@ class PdfViewPinch extends StatefulWidget { /// Default page builder @override - _PdfViewPinchState createState() => _PdfViewPinchState(); + State createState() => _PdfViewPinchState(); } class _PdfViewPinchState extends State @@ -569,29 +569,6 @@ class _PdfViewPinchState extends State child: Container( width: page.rect!.width, height: page.rect!.height, - child: Stack(children: [ - ValueListenableBuilder( - valueListenable: page._previewNotifier, - builder: (context, value, child) => page.preview != null - ? Positioned.fill( - child: PdfTexture(textureId: page.preview!.id), - ) - : Container(), - ), - ValueListenableBuilder( - valueListenable: page._realSizeNotifier, - builder: (context, value, child) => - page.realSizeOverlayRect != null && page.realSize != null - ? Positioned( - left: page.realSizeOverlayRect!.left, - top: page.realSizeOverlayRect!.top, - width: page.realSizeOverlayRect!.width, - height: page.realSizeOverlayRect!.height, - child: PdfTexture(textureId: page.realSize!.id), - ) - : Container(), - ), - ]), decoration: const BoxDecoration( color: Color.fromARGB(255, 250, 250, 250), boxShadow: [ @@ -602,6 +579,31 @@ class _PdfViewPinchState extends State ), ], ), + child: Stack( + children: [ + ValueListenableBuilder( + valueListenable: page._previewNotifier, + builder: (context, value, child) => page.preview != null + ? Positioned.fill( + child: PdfTexture(textureId: page.preview!.id), + ) + : Container(), + ), + ValueListenableBuilder( + valueListenable: page._realSizeNotifier, + builder: (context, value, child) => + page.realSizeOverlayRect != null && page.realSize != null + ? Positioned( + left: page.realSizeOverlayRect!.left, + top: page.realSizeOverlayRect!.top, + width: page.realSizeOverlayRect!.width, + height: page.realSizeOverlayRect!.height, + child: PdfTexture(textureId: page.realSize!.id), + ) + : Container(), + ), + ], + ), ), ); } diff --git a/packages/pdfx/lib/src/viewer/simple/pdf_view.dart b/packages/pdfx/lib/src/viewer/simple/pdf_view.dart index 917b0be0..b2e8b179 100644 --- a/packages/pdfx/lib/src/viewer/simple/pdf_view.dart +++ b/packages/pdfx/lib/src/viewer/simple/pdf_view.dart @@ -73,7 +73,7 @@ class PdfView extends StatefulWidget { ); @override - _PdfViewState createState() => _PdfViewState(); + State createState() => _PdfViewState(); } class _PdfViewState extends State { diff --git a/packages/pdfx/lib/src/viewer/wrappers/implementations/pdf_texture_web.dart b/packages/pdfx/lib/src/viewer/wrappers/implementations/pdf_texture_web.dart index 1a94ed10..59f9f0db 100644 --- a/packages/pdfx/lib/src/viewer/wrappers/implementations/pdf_texture_web.dart +++ b/packages/pdfx/lib/src/viewer/wrappers/implementations/pdf_texture_web.dart @@ -15,7 +15,7 @@ class PdfTexture extends StatefulWidget { final int textureId; @override - _PdfTextureState createState() => _PdfTextureState(); + State createState() => _PdfTextureState(); RgbaData? get data => js_util.getProperty(html.window, 'pdfx_texture_$textureId') as RgbaData?; diff --git a/packages/pdfx/test/pdfx_test.dart b/packages/pdfx/test/pdfx_test.dart index 035b6d29..2bb6d6e9 100644 --- a/packages/pdfx/test/pdfx_test.dart +++ b/packages/pdfx/test/pdfx_test.dart @@ -1,3 +1,4 @@ +// ignore: unnecessary_import import 'dart:typed_data'; import 'package:flutter/foundation.dart' show kIsWeb; @@ -17,10 +18,10 @@ void main() { PdfxPlatform.instance = PdfxPlatformMethodChannel(); final List log = []; PdfDocument? document; - late Uint8List _testData; + late Uint8List testData; setUpAll(() async { - _testData = Uint8List.fromList(imageBytes); + testData = Uint8List.fromList(imageBytes); const MethodChannel('io.scer.pdf_renderer') .setMockMethodCallHandler((MethodCall methodCall) async { @@ -56,7 +57,7 @@ void main() { 'width': methodCall.arguments['width'], 'height': methodCall.arguments['height'], 'path': 'test/image.png', - 'data': _testData, + 'data': testData, }; default: return null; @@ -99,11 +100,11 @@ void main() { }); test('from data', () async { - document = await PdfDocument.openData(_testData); + document = await PdfDocument.openData(testData); expect(log, [ isMethodCall( 'open.document.data', - arguments: _testData, + arguments: testData, ), ]); expect(document!.pagesCount, 3); @@ -172,7 +173,7 @@ void main() { ), ]); - expect(pageImage.bytes, _testData); + expect(pageImage.bytes, testData); expect(pageImage.format, PdfPageImageFormat.jpeg); expect(pageImage.width, width); expect(pageImage.height, height); diff --git a/script/configs/custom_analysis.yaml b/script/configs/custom_analysis.yaml index 3cbfea4a..40678d9d 100644 --- a/script/configs/custom_analysis.yaml +++ b/script/configs/custom_analysis.yaml @@ -1,6 +1,14 @@ -- auto_animated +# Plugins that deliberately use their own analysis_options.yaml. +# +# This only exists to allow incrementally adopting new analysis options in +# cases where a new option can't be applied to the entire repository at +# once. Do not add anything to this file without an issue reference and +# a concrete plan for removing it relatively quickly. +# +# DO NOT move or delete this file without updating +# https://github.com/dart-lang/sdk/blob/master/tools/bots/flutter/analyze_flutter_plugins.sh +# which references this file from source, but out-of-repo. +# Contact stuartmorgan or devoncarew for assistance if necessary. - epub_view - explorer -- flutter_color -- native_pdf_renderer -- native_pdf_view +- pdfx diff --git a/script/configs/exclude_integration_android.yaml b/script/configs/exclude_integration_android.yaml index fcadda33..653f3516 100644 --- a/script/configs/exclude_integration_android.yaml +++ b/script/configs/exclude_integration_android.yaml @@ -1,2 +1,2 @@ -- native_pdf_renderer -- native_pdf_view +# No integration tests to run: +- espresso diff --git a/script/configs/exclude_integration_ios.yaml b/script/configs/exclude_integration_ios.yaml index fcadda33..95a58e71 100644 --- a/script/configs/exclude_integration_ios.yaml +++ b/script/configs/exclude_integration_ios.yaml @@ -1,2 +1,3 @@ -- native_pdf_renderer -- native_pdf_view +# +- pdfx +- epub_view diff --git a/script/configs/exclude_integration_macos.yaml b/script/configs/exclude_integration_macos.yaml index fcadda33..792d6005 100644 --- a/script/configs/exclude_integration_macos.yaml +++ b/script/configs/exclude_integration_macos.yaml @@ -1,2 +1 @@ -- native_pdf_renderer -- native_pdf_view +# diff --git a/script/configs/exclude_integration_web.yaml b/script/configs/exclude_integration_web.yaml index fcadda33..792d6005 100644 --- a/script/configs/exclude_integration_web.yaml +++ b/script/configs/exclude_integration_web.yaml @@ -1,2 +1 @@ -- native_pdf_renderer -- native_pdf_view +# diff --git a/script/configs/exclude_integration_win32.yaml b/script/configs/exclude_integration_win32.yaml index fcadda33..792d6005 100644 --- a/script/configs/exclude_integration_win32.yaml +++ b/script/configs/exclude_integration_win32.yaml @@ -1,2 +1 @@ -- native_pdf_renderer -- native_pdf_view +# diff --git a/script/configs/exclude_native_ios.yaml b/script/configs/exclude_native_ios.yaml new file mode 100644 index 00000000..42b02c7b --- /dev/null +++ b/script/configs/exclude_native_ios.yaml @@ -0,0 +1 @@ +- pdfx diff --git a/script/configs/exclude_native_unit_android.yaml b/script/configs/exclude_native_unit_android.yaml index fcadda33..45197b94 100644 --- a/script/configs/exclude_native_unit_android.yaml +++ b/script/configs/exclude_native_unit_android.yaml @@ -1,2 +1,2 @@ -- native_pdf_renderer -- native_pdf_view +# No need for unit tests: +- espresso diff --git a/script/tool/lib/src/build_examples_command.dart b/script/tool/lib/src/build_examples_command.dart index 1aade357..d211106c 100644 --- a/script/tool/lib/src/build_examples_command.dart +++ b/script/tool/lib/src/build_examples_command.dart @@ -115,7 +115,7 @@ class BuildExamplesCommand extends PackageLoopingCommand { Future initializeRun() async { final List platformFlags = _platforms.keys.toList(); platformFlags.sort(); - if (!platformFlags.any((String platform) => getBoolArg(platform))) { + if (!platformFlags.any(getBoolArg)) { printError( 'None of ${platformFlags.map((String platform) => '--$platform').join(', ')} ' 'were specified. At least one platform must be provided.'); @@ -142,9 +142,8 @@ class BuildExamplesCommand extends PackageLoopingCommand { .toSet() : requestedPlatforms.toSet(); - String platformDisplayList(Iterable<_PlatformDetails> platforms) { - return platforms.map((_PlatformDetails p) => p.label).join(', '); - } + String platformDisplayList(Iterable<_PlatformDetails> platforms) => + platforms.map((_PlatformDetails p) => p.label).join(', '); if (buildPlatforms.isEmpty) { final String unsupported = requestedPlatforms.length == 1 diff --git a/script/tool/lib/src/common/cmake.dart b/script/tool/lib/src/common/cmake.dart index 04ad8802..e5ad46e5 100644 --- a/script/tool/lib/src/common/cmake.dart +++ b/script/tool/lib/src/common/cmake.dart @@ -63,9 +63,7 @@ class CMakeProject { /// /// Assumes the project has been built at least once, such that the CMake /// generation step has run. - String getCmakeCommand() { - return _cmakeCommand; - } + String getCmakeCommand() => _cmakeCommand; /// Returns the CMake command to run build commands for this project. This is /// used to initialize _cmakeCommand, and should not be called directly. @@ -102,17 +100,16 @@ class CMakeProject { Future runBuild( String target, { List arguments = const [], - }) { - return processRunner.runAndStream( - getCmakeCommand(), - [ - '--build', - buildDirectory.path, - '--target', - target, - if (platform.isWindows) ...['--config', buildMode], - ...arguments, - ], - ); - } + }) => + processRunner.runAndStream( + getCmakeCommand(), + [ + '--build', + buildDirectory.path, + '--target', + target, + if (platform.isWindows) ...['--config', buildMode], + ...arguments, + ], + ); } diff --git a/script/tool/lib/src/common/git_version_finder.dart b/script/tool/lib/src/common/git_version_finder.dart index 32d30e60..b90b4554 100644 --- a/script/tool/lib/src/common/git_version_finder.dart +++ b/script/tool/lib/src/common/git_version_finder.dart @@ -21,14 +21,11 @@ class GitVersionFinder { /// The base sha used to get diff. String? _baseSha; - static bool _isPubspec(String file) { - return file.trim().endsWith('pubspec.yaml'); - } + static bool _isPubspec(String file) => file.trim().endsWith('pubspec.yaml'); /// Get a list of all the pubspec.yaml file that is changed. - Future> getChangedPubSpecs() async { - return (await getChangedFiles()).where(_isPubspec).toList(); - } + Future> getChangedPubSpecs() async => + (await getChangedFiles()).where(_isPubspec).toList(); /// Get a list of all the changed files. Future> getChangedFiles( diff --git a/script/tool/lib/src/common/gradle.dart b/script/tool/lib/src/common/gradle.dart index 74653607..f8f5cd5f 100644 --- a/script/tool/lib/src/common/gradle.dart +++ b/script/tool/lib/src/common/gradle.dart @@ -46,11 +46,10 @@ class GradleProject { Future runCommand( String target, { List arguments = const [], - }) { - return processRunner.runAndStream( - gradleWrapper.path, - [target, ...arguments], - workingDir: androidDirectory, - ); - } + }) => + processRunner.runAndStream( + gradleWrapper.path, + [target, ...arguments], + workingDir: androidDirectory, + ); } diff --git a/script/tool/lib/src/common/package_looping_command.dart b/script/tool/lib/src/common/package_looping_command.dart index 1a194bd4..d8a33c56 100644 --- a/script/tool/lib/src/common/package_looping_command.dart +++ b/script/tool/lib/src/common/package_looping_command.dart @@ -518,7 +518,6 @@ abstract class PackageLoopingCommand extends PluginCommand { /// Returns a duration [d] formatted as minutes:seconds. Does not use hours, /// since time logging is primarily intended for CI, where durations should /// always be less than an hour. - String _formatDurationAsRelativeTime(Duration d) { - return '${d.inMinutes}:${(d.inSeconds % 60).toString().padLeft(2, '0')}'; - } + String _formatDurationAsRelativeTime(Duration d) => + '${d.inMinutes}:${(d.inSeconds % 60).toString().padLeft(2, '0')}'; } diff --git a/script/tool/lib/src/common/plugin_command.dart b/script/tool/lib/src/common/plugin_command.dart index be9fb23e..a6a1932b 100644 --- a/script/tool/lib/src/common/plugin_command.dart +++ b/script/tool/lib/src/common/plugin_command.dart @@ -181,14 +181,10 @@ abstract class PluginCommand extends Command { } /// Convenience accessor for boolean arguments. - bool getBoolArg(String key) { - return (argResults![key] as bool?) ?? false; - } + bool getBoolArg(String key) => (argResults![key] as bool?) ?? false; /// Convenience accessor for String arguments. - String getStringArg(String key) { - return (argResults![key] as String?) ?? ''; - } + String getStringArg(String key) => (argResults![key] as String?) ?? ''; /// Convenience accessor for List arguments. List getStringListArg(String key) { @@ -437,18 +433,15 @@ abstract class PluginCommand extends Command { /// Returns the files contained, recursively, within the packages /// involved in this command execution. - Stream getFiles() { - return getTargetPackages().asyncExpand( - (PackageEnumerationEntry entry) => getFilesForPackage(entry.package)); - } + Stream getFiles() => getTargetPackages().asyncExpand( + (PackageEnumerationEntry entry) => getFilesForPackage(entry.package)); /// Returns the files contained, recursively, within [package]. - Stream getFilesForPackage(RepositoryPackage package) { - return package.directory - .list(recursive: true, followLinks: false) - .where((FileSystemEntity entity) => entity is File) - .cast(); - } + Stream getFilesForPackage(RepositoryPackage package) => + package.directory + .list(recursive: true, followLinks: false) + .where((FileSystemEntity entity) => entity is File) + .cast(); /// Retrieve an instance of [GitVersionFinder] based on `_baseShaArg` and [gitDir]. /// @@ -477,10 +470,9 @@ abstract class PluginCommand extends Command { // if .../packages/parentName/candidatePackageName/... // looks like a path in a federated plugin package (candidatePackageName) // rather than a top-level package (parentName). - bool isFederatedPackage(String candidatePackageName, String parentName) { - return candidatePackageName == parentName || - candidatePackageName.startsWith('${parentName}_'); - } + bool isFederatedPackage(String candidatePackageName, String parentName) => + candidatePackageName == parentName || + candidatePackageName.startsWith('${parentName}_'); for (final String path in changedFiles) { final List pathComponents = p.posix.split(path); diff --git a/script/tool/lib/src/common/plugin_utils.dart b/script/tool/lib/src/common/plugin_utils.dart index f33d3d73..e0318364 100644 --- a/script/tool/lib/src/common/plugin_utils.dart +++ b/script/tool/lib/src/common/plugin_utils.dart @@ -17,9 +17,8 @@ enum PlatformSupport { } /// Returns true if [package] is a Flutter plugin. -bool isFlutterPlugin(RepositoryPackage package) { - return _readPluginPubspecSection(package) != null; -} +bool isFlutterPlugin(RepositoryPackage package) => + _readPluginPubspecSection(package) != null; /// Returns true if [package] is a Flutter [platform] plugin. /// diff --git a/script/tool/lib/src/common/pub_version_finder.dart b/script/tool/lib/src/common/pub_version_finder.dart index 572cb913..5138015f 100644 --- a/script/tool/lib/src/common/pub_version_finder.dart +++ b/script/tool/lib/src/common/pub_version_finder.dart @@ -46,8 +46,8 @@ class PubVersionFinder { } final List versions = (json.decode(response.body)['versions'] as List) - .map((final dynamic versionString) => - Version.parse(versionString as String)) + .map( + (final versionString) => Version.parse(versionString as String)) .toList(); return PubVersionFinderResponse( diff --git a/script/tool/lib/src/common/repository_package.dart b/script/tool/lib/src/common/repository_package.dart index 5f448d36..74d3c9b5 100644 --- a/script/tool/lib/src/common/repository_package.dart +++ b/script/tool/lib/src/common/repository_package.dart @@ -146,7 +146,7 @@ class RepositoryPackage { // example directory for other Dart packages. return exampleDirectory .listSync() - .where((FileSystemEntity entity) => isPackage(entity)) + .where(isPackage) // isPackage guarantees that the cast to Directory is safe. .map((FileSystemEntity entity) => RepositoryPackage(entity as Directory)); diff --git a/script/tool/lib/src/create_all_plugins_app_command.dart b/script/tool/lib/src/create_all_plugins_app_command.dart index 595779b8..5c79d069 100644 --- a/script/tool/lib/src/create_all_plugins_app_command.dart +++ b/script/tool/lib/src/create_all_plugins_app_command.dart @@ -199,8 +199,7 @@ class CreateAllPluginsAppCommand extends PluginCommand { return pathDependencies; } - String _pubspecToString(Pubspec pubspec) { - return ''' + String _pubspecToString(Pubspec pubspec) => ''' ### Generated file. Do not edit. Run `pub global run flutter_plugin_tools gen-pubspec` to update. name: ${pubspec.name} description: ${pubspec.description} @@ -216,7 +215,6 @@ dependency_overrides:${_pubspecMapString(pubspec.dependencyOverrides)} dev_dependencies:${_pubspecMapString(pubspec.devDependencies)} ###'''; - } String _pubspecMapString(Map values) { final StringBuffer buffer = StringBuffer(); diff --git a/script/tool/lib/src/dependabot_check_command.dart b/script/tool/lib/src/dependabot_check_command.dart index 5aa762e9..ed7d3e07 100644 --- a/script/tool/lib/src/dependabot_check_command.dart +++ b/script/tool/lib/src/dependabot_check_command.dart @@ -58,8 +58,8 @@ class DependabotCheckCommand extends PackageLoopingCommand { const String typeKey = 'package-ecosystem'; const String dirKey = 'directory'; _gradleDirs = entries - .where((dynamic entry) => entry[typeKey] == 'gradle') - .map((dynamic entry) => (entry as YamlMap)[dirKey] as String) + .where((entry) => entry[typeKey] == 'gradle') + .map((entry) => (entry as YamlMap)[dirKey] as String) .toSet(); } diff --git a/script/tool/lib/src/drive_examples_command.dart b/script/tool/lib/src/drive_examples_command.dart index 45e20c0f..09d8fce0 100644 --- a/script/tool/lib/src/drive_examples_command.dart +++ b/script/tool/lib/src/drive_examples_command.dart @@ -68,9 +68,7 @@ class DriveExamplesCommand extends PackageLoopingCommand { platformWeb, platformWindows, ]; - final int platformCount = platformSwitches - .where((String platform) => getBoolArg(platform)) - .length; + final int platformCount = platformSwitches.where(getBoolArg).length; // The flutter tool currently doesn't accept multiple device arguments: // https://github.com/flutter/flutter/issues/35733 // If that is implemented, this check can be relaxed. diff --git a/script/tool/lib/src/firebase_test_lab_command.dart b/script/tool/lib/src/firebase_test_lab_command.dart index 4505259b..3fdfd2ff 100644 --- a/script/tool/lib/src/firebase_test_lab_command.dart +++ b/script/tool/lib/src/firebase_test_lab_command.dart @@ -345,14 +345,14 @@ class FirebaseTestLabCommand extends PackageLoopingCommand { /// annotation that means that the test will reports the results of running /// the Dart integration tests. Future _testsContainDartIntegrationTestRunner( - Directory uiTestDirectory) async { - return uiTestDirectory - .list(recursive: true, followLinks: false) - .where((FileSystemEntity entity) => entity is File) - .cast() - .any((File file) { - return file.basename.endsWith('.java') && - file.readAsStringSync().contains('@RunWith(FlutterTestRunner.class)'); - }); - } + Directory uiTestDirectory) async => + uiTestDirectory + .list(recursive: true, followLinks: false) + .where((FileSystemEntity entity) => entity is File) + .cast() + .any((File file) => + file.basename.endsWith('.java') && + file + .readAsStringSync() + .contains('@RunWith(FlutterTestRunner.class)')); } diff --git a/script/tool/lib/src/format_command.dart b/script/tool/lib/src/format_command.dart index f640cbaa..bb788ac4 100644 --- a/script/tool/lib/src/format_command.dart +++ b/script/tool/lib/src/format_command.dart @@ -240,10 +240,9 @@ class FormatCommand extends PluginCommand { } Iterable _getPathsWithExtensions( - Iterable files, Set extensions) { - return files.where( - (String filePath) => extensions.contains(path.extension(filePath))); - } + Iterable files, Set extensions) => + files.where( + (String filePath) => extensions.contains(path.extension(filePath))); Future _getGoogleFormatterPath() async { final String javaFormatterPath = path.join( diff --git a/script/tool/lib/src/license_check_command.dart b/script/tool/lib/src/license_check_command.dart index 5e74d846..068f488f 100644 --- a/script/tool/lib/src/license_check_command.dart +++ b/script/tool/lib/src/license_check_command.dart @@ -193,11 +193,10 @@ class LicenseCheckCommand extends PluginCommand { String comment, { String prefix = '', String suffix = '', - }) { - return '$prefix${comment}Copyright 2013 The Flutter Authors. All rights reserved.\n' - '${comment}Use of this source code is governed by a BSD-style license that can be\n' - '${comment}found in the LICENSE file.$suffix\n'; - } + }) => + '$prefix${comment}Copyright 2013 The Flutter Authors. All rights reserved.\n' + '${comment}Use of this source code is governed by a BSD-style license that can be\n' + '${comment}found in the LICENSE file.$suffix\n'; /// Checks all license blocks for [codeFiles], returning any that fail /// validation. @@ -276,9 +275,8 @@ class LicenseCheckCommand extends PluginCommand { _ignoredFullBasenameList.contains(p.basename(path))); } - bool _isThirdParty(File file) { - return path.split(file.path).contains('third_party'); - } + bool _isThirdParty(File file) => + path.split(file.path).contains('third_party'); Future> _getAllFiles() => packagesDir.parent .list(recursive: true, followLinks: false) diff --git a/script/tool/lib/src/native_test_command.dart b/script/tool/lib/src/native_test_command.dart index 81b13cbb..14e8eba4 100644 --- a/script/tool/lib/src/native_test_command.dart +++ b/script/tool/lib/src/native_test_command.dart @@ -90,9 +90,7 @@ this command. platformMacOS: _PlatformDetails('macOS', _testMacOS), platformWindows: _PlatformDetails('Windows', _testWindows), }; - _requestedPlatforms = _platforms.keys - .where((String platform) => getBoolArg(platform)) - .toList(); + _requestedPlatforms = _platforms.keys.where(getBoolArg).toList(); _requestedPlatforms.sort(); if (_requestedPlatforms.isEmpty) { @@ -197,19 +195,18 @@ this command. Future<_PlatformResult> _testAndroid( RepositoryPackage plugin, _TestMode mode) async { - bool exampleHasUnitTests(RepositoryPackage example) { - return example - .platformDirectory(FlutterPlatform.android) - .childDirectory('app') - .childDirectory('src') - .childDirectory('test') - .existsSync() || - plugin - .platformDirectory(FlutterPlatform.android) - .childDirectory('src') - .childDirectory('test') - .existsSync(); - } + bool exampleHasUnitTests(RepositoryPackage example) => + example + .platformDirectory(FlutterPlatform.android) + .childDirectory('app') + .childDirectory('src') + .childDirectory('test') + .existsSync() || + plugin + .platformDirectory(FlutterPlatform.android) + .childDirectory('src') + .childDirectory('test') + .existsSync(); bool exampleHasNativeIntegrationTests(RepositoryPackage example) { final Directory integrationTestDirectory = example @@ -333,14 +330,12 @@ this command. return _PlatformResult(RunState.succeeded); } - Future<_PlatformResult> _testIOS(RepositoryPackage plugin, _TestMode mode) { - return _runXcodeTests(plugin, 'iOS', mode, - extraFlags: _iOSDestinationFlags); - } + Future<_PlatformResult> _testIOS(RepositoryPackage plugin, _TestMode mode) => + _runXcodeTests(plugin, 'iOS', mode, extraFlags: _iOSDestinationFlags); - Future<_PlatformResult> _testMacOS(RepositoryPackage plugin, _TestMode mode) { - return _runXcodeTests(plugin, 'macOS', mode); - } + Future<_PlatformResult> _testMacOS( + RepositoryPackage plugin, _TestMode mode) => + _runXcodeTests(plugin, 'macOS', mode); /// Runs all applicable tests for [plugin], printing status and returning /// the test result. @@ -452,10 +447,9 @@ this command. return _PlatformResult(RunState.skipped); } - bool isTestBinary(File file) { - return file.basename.endsWith('_test.exe') || - file.basename.endsWith('_tests.exe'); - } + bool isTestBinary(File file) => + file.basename.endsWith('_test.exe') || + file.basename.endsWith('_tests.exe'); return _runGoogleTestTests(plugin, 'Windows', 'Debug', isTestBinary: isTestBinary); @@ -467,10 +461,8 @@ this command. return _PlatformResult(RunState.skipped); } - bool isTestBinary(File file) { - return file.basename.endsWith('_test') || - file.basename.endsWith('_tests'); - } + bool isTestBinary(File file) => + file.basename.endsWith('_test') || file.basename.endsWith('_tests'); // Since Linux uses a single-config generator, building-examples only // generates the build files for release, so the tests have to be run in diff --git a/script/tool/lib/src/publish_check_command.dart b/script/tool/lib/src/publish_check_command.dart index af8eac22..20174d4c 100644 --- a/script/tool/lib/src/publish_check_command.dart +++ b/script/tool/lib/src/publish_check_command.dart @@ -152,7 +152,7 @@ class PublishCheckCommand extends PackageLoopingCommand { outputBuffer.write(output); } }, - onDone: () => stdOutCompleter.complete(), + onDone: stdOutCompleter.complete, ); final Completer stdInCompleter = Completer(); @@ -167,7 +167,7 @@ class PublishCheckCommand extends PackageLoopingCommand { outputBuffer.write(output); } }, - onDone: () => stdInCompleter.complete(), + onDone: stdInCompleter.complete, ); if (await process.exitCode == 0) { diff --git a/script/tool/lib/src/publish_plugin_command.dart b/script/tool/lib/src/publish_plugin_command.dart index 7aa70bd4..74e5e4b0 100644 --- a/script/tool/lib/src/publish_plugin_command.dart +++ b/script/tool/lib/src/publish_plugin_command.dart @@ -353,8 +353,8 @@ Safe to ignore if the package is deleted in this commit. final io.Process publish = await processRunner.start( flutterCommand, ['pub', 'publish', ..._publishFlags], workingDirectory: package.directory); - publish.stdout.transform(utf8.decoder).listen((String data) => print(data)); - publish.stderr.transform(utf8.decoder).listen((String data) => print(data)); + publish.stdout.transform(utf8.decoder).listen(print); + publish.stderr.transform(utf8.decoder).listen(print); _stdinSubscription ??= _stdin .transform(utf8.decoder) .listen((String data) => publish.stdin.writeln(data)); @@ -388,7 +388,6 @@ Safe to ignore if the package is deleted in this commit. required String tag, required _RemoteInfo remote, }) async { - assert(remote != null && tag != null); if (!getBoolArg(_dryRunFlag)) { final io.ProcessResult result = await (await gitDir).runCommand( ['push', remote.name, tag], @@ -423,9 +422,7 @@ If running this command on CI, you can set the pub credential content in the $_p /// Returns the correct path where the pub credential is stored. @visibleForTesting - static String getCredentialPath() { - return _credentialsPath; - } + static String getCredentialPath() => _credentialsPath; } /// The path in which pub expects to find its credentials file. diff --git a/script/tool/lib/src/readme_check_command.dart b/script/tool/lib/src/readme_check_command.dart index 6e79b736..98cda252 100644 --- a/script/tool/lib/src/readme_check_command.dart +++ b/script/tool/lib/src/readme_check_command.dart @@ -264,8 +264,7 @@ ${indentation * 2}Please use standard capitalizations: ${sortedListString(expect /// Returns true if the README still has the boilerplate from the /// `flutter create` templates. - bool _containsTemplateBoilerplate(List readmeLines) { - return readmeLines.any((String line) => - line.contains('For help getting started with Flutter')); - } + bool _containsTemplateBoilerplate(List readmeLines) => + readmeLines.any((String line) => + line.contains('For help getting started with Flutter')); } diff --git a/script/tool/lib/src/update_release_info_command.dart b/script/tool/lib/src/update_release_info_command.dart index b998615e..f5362868 100644 --- a/script/tool/lib/src/update_release_info_command.dart +++ b/script/tool/lib/src/update_release_info_command.dart @@ -256,15 +256,14 @@ class UpdateReleaseInfoCommand extends PackageLoopingCommand { /// ``` /// [ '* A line.', '* Another line.' ] /// ``` - Iterable _changelogAdditionsAsList({String listMarker = '*'}) { - return getStringArg(_changelogFlag).split('\n').map((String entry) { - String standardizedEntry = entry.trim(); - if (!standardizedEntry.endsWith('.')) { - standardizedEntry = '$standardizedEntry.'; - } - return '$listMarker $standardizedEntry'; - }); - } + Iterable _changelogAdditionsAsList({String listMarker = '*'}) => + getStringArg(_changelogFlag).split('\n').map((String entry) { + String standardizedEntry = entry.trim(); + if (!standardizedEntry.endsWith('.')) { + standardizedEntry = '$standardizedEntry.'; + } + return '$listMarker $standardizedEntry'; + }); /// Updates the version in [package]'s pubspec according to [type], returning /// the new version, or null if there was an error updating the version. diff --git a/script/tool/lib/src/version_check_command.dart b/script/tool/lib/src/version_check_command.dart index 246382df..7efd7ff7 100644 --- a/script/tool/lib/src/version_check_command.dart +++ b/script/tool/lib/src/version_check_command.dart @@ -464,7 +464,7 @@ ${indentation}The first version listed in CHANGELOG.md is $fromChangeLog. // If NEXT wasn't the first section, it should not exist at all. if (!hasNextSection) { final RegExp nextRegex = RegExp(r'^#+\s*NEXT\s*$'); - if (lines.any((String line) => nextRegex.hasMatch(line))) { + if (lines.any(nextRegex.hasMatch)) { printError(badNextErrorMessage); return false; } diff --git a/script/tool/test/common/pub_version_finder_test.dart b/script/tool/test/common/pub_version_finder_test.dart index 1692cf21..59d1713a 100644 --- a/script/tool/test/common/pub_version_finder_test.dart +++ b/script/tool/test/common/pub_version_finder_test.dart @@ -14,9 +14,8 @@ import 'package:test/test.dart'; void main() { test('Package does not exist.', () async { - final MockClient mockClient = MockClient((http.Request request) async { - return http.Response('', 404); - }); + final MockClient mockClient = + MockClient((http.Request request) async => http.Response('', 404)); final PubVersionFinder finder = PubVersionFinder(httpClient: mockClient); final PubVersionFinderResponse response = await finder.getPackageVersion(packageName: 'some_package'); @@ -28,9 +27,8 @@ void main() { }); test('HTTP error when getting versions from pub', () async { - final MockClient mockClient = MockClient((http.Request request) async { - return http.Response('', 400); - }); + final MockClient mockClient = + MockClient((http.Request request) async => http.Response('', 400)); final PubVersionFinder finder = PubVersionFinder(httpClient: mockClient); final PubVersionFinderResponse response = await finder.getPackageVersion(packageName: 'some_package'); @@ -59,9 +57,8 @@ void main() { '1.0.0', ], }; - final MockClient mockClient = MockClient((http.Request request) async { - return http.Response(json.encode(httpResponse), 200); - }); + final MockClient mockClient = MockClient((http.Request request) async => + http.Response(json.encode(httpResponse), 200)); final PubVersionFinder finder = PubVersionFinder(httpClient: mockClient); final PubVersionFinderResponse response = await finder.getPackageVersion(packageName: 'some_package'); diff --git a/script/tool/test/native_test_command_test.dart b/script/tool/test/native_test_command_test.dart index d420184b..c5ce3fb6 100644 --- a/script/tool/test/native_test_command_test.dart +++ b/script/tool/test/native_test_command_test.dart @@ -106,21 +106,20 @@ void main() { // Returns the ProcessCall to expect for checking the targets present in // the [package]'s [platform]/Runner.xcodeproj. - ProcessCall _getTargetCheckCall(Directory package, String platform) { - return ProcessCall( - 'xcrun', - [ - 'xcodebuild', - '-list', - '-json', - '-project', - package - .childDirectory(platform) - .childDirectory('Runner.xcodeproj') - .path, - ], - null); - } + ProcessCall _getTargetCheckCall(Directory package, String platform) => + ProcessCall( + 'xcrun', + [ + 'xcodebuild', + '-list', + '-json', + '-project', + package + .childDirectory(platform) + .childDirectory('Runner.xcodeproj') + .path, + ], + null); // Returns the ProcessCall to expect for running the tests in the // workspace [platform]/Runner.xcworkspace, with the given extra flags. @@ -129,43 +128,40 @@ void main() { String platform, { String? destination, List extraFlags = const [], - }) { - return ProcessCall( - 'xcrun', - [ - 'xcodebuild', - 'test', - '-workspace', - '$platform/Runner.xcworkspace', - '-scheme', - 'Runner', - '-configuration', - 'Debug', - if (destination != null) ...['-destination', destination], - ...extraFlags, - 'GCC_TREAT_WARNINGS_AS_ERRORS=YES', - ], - package.path); - } + }) => + ProcessCall( + 'xcrun', + [ + 'xcodebuild', + 'test', + '-workspace', + '$platform/Runner.xcworkspace', + '-scheme', + 'Runner', + '-configuration', + 'Debug', + if (destination != null) ...['-destination', destination], + ...extraFlags, + 'GCC_TREAT_WARNINGS_AS_ERRORS=YES', + ], + package.path); // Returns the ProcessCall to expect for build the Linux unit tests for the // given plugin. - ProcessCall _getLinuxBuildCall(RepositoryPackage plugin) { - return ProcessCall( - 'cmake', - [ - '--build', - getExampleDir(plugin) - .childDirectory('build') - .childDirectory('linux') - .childDirectory('x64') - .childDirectory('release') - .path, - '--target', - 'unit_tests' - ], - null); - } + ProcessCall _getLinuxBuildCall(RepositoryPackage plugin) => ProcessCall( + 'cmake', + [ + '--build', + getExampleDir(plugin) + .childDirectory('build') + .childDirectory('linux') + .childDirectory('x64') + .childDirectory('release') + .path, + '--target', + 'unit_tests' + ], + null); test('fails if no platforms are provided', () async { Error? commandError; @@ -1598,22 +1594,20 @@ void main() { // Returns the ProcessCall to expect for build the Windows unit tests for // the given plugin. - ProcessCall _getWindowsBuildCall(RepositoryPackage plugin) { - return ProcessCall( - _fakeCmakeCommand, - [ - '--build', - getExampleDir(plugin) - .childDirectory('build') - .childDirectory('windows') - .path, - '--target', - 'unit_tests', - '--config', - 'Debug' - ], - null); - } + ProcessCall _getWindowsBuildCall(RepositoryPackage plugin) => ProcessCall( + _fakeCmakeCommand, + [ + '--build', + getExampleDir(plugin) + .childDirectory('build') + .childDirectory('windows') + .path, + '--target', + 'unit_tests', + '--config', + 'Debug' + ], + null); group('Windows', () { test('runs unit tests', () async { diff --git a/script/tool/test/publish_plugin_command_test.dart b/script/tool/test/publish_plugin_command_test.dart index f3be3b48..1db6a049 100644 --- a/script/tool/test/publish_plugin_command_test.dart +++ b/script/tool/test/publish_plugin_command_test.dart @@ -907,10 +907,9 @@ class MockStdin extends Mock implements io.Stdin { @override StreamSubscription> listen(void Function(List event)? onData, - {Function? onError, void Function()? onDone, bool? cancelOnError}) { - return _controller.stream.listen(onData, - onError: onError, onDone: onDone, cancelOnError: cancelOnError); - } + {Function? onError, void Function()? onDone, bool? cancelOnError}) => + _controller.stream.listen(onData, + onError: onError, onDone: onDone, cancelOnError: cancelOnError); @override String? readLineSync( diff --git a/script/tool/test/util.dart b/script/tool/test/util.dart index 041d9336..d479799f 100644 --- a/script/tool/test/util.dart +++ b/script/tool/test/util.dart @@ -81,9 +81,8 @@ class PlatformDetails { /// /// This returns a Directory rather than a RepositoryPackage because there is no /// guarantee that the returned directory is a package. -Directory getExampleDir(RepositoryPackage package) { - return package.directory.childDirectory('example'); -} +Directory getExampleDir(RepositoryPackage package) => + package.directory.childDirectory('example'); /// Creates a plugin package with the given [name] in [packagesDirectory]. /// @@ -447,12 +446,11 @@ class ProcessCall { final String? workingDir; @override - bool operator ==(dynamic other) { - return other is ProcessCall && - executable == other.executable && - listsEqual(args, other.args) && - workingDir == other.workingDir; - } + bool operator ==(Object other) => + other is ProcessCall && + executable == other.executable && + listsEqual(args, other.args) && + workingDir == other.workingDir; @override int get hashCode => Object.hash(executable, args, workingDir); diff --git a/script/tool/test/version_check_command_test.dart b/script/tool/test/version_check_command_test.dart index 8f8d510f..796ba347 100644 --- a/script/tool/test/version_check_command_test.dart +++ b/script/tool/test/version_check_command_test.dart @@ -76,10 +76,9 @@ void main() { // Default to simulating the plugin never having been published. mockHttpStatus = 404; mockHttpResponse = null; - final MockClient mockClient = MockClient((http.Request request) async { - return http.Response(json.encode(mockHttpResponse), - mockHttpResponse == null ? mockHttpStatus : 200); - }); + final MockClient mockClient = MockClient((http.Request request) async => + http.Response(json.encode(mockHttpResponse), + mockHttpResponse == null ? mockHttpStatus : 200)); processRunner = RecordingProcessRunner(); final VersionCheckCommand command = VersionCheckCommand(packagesDir, @@ -728,18 +727,17 @@ This is necessary because of X, Y, and Z group('missing change detection', () { Future> _runWithMissingChangeDetection( - List extraArgs, - {void Function(Error error)? errorHandler}) async { - return runCapturingPrint( - runner, - [ - 'version-check', - '--base-sha=main', - '--check-for-missing-changes', - ...extraArgs, - ], - errorHandler: errorHandler); - } + List extraArgs, + {void Function(Error error)? errorHandler}) async => + runCapturingPrint( + runner, + [ + 'version-check', + '--base-sha=main', + '--check-for-missing-changes', + ...extraArgs, + ], + errorHandler: errorHandler); test('passes for unchanged packages', () async { final RepositoryPackage plugin =