From 834054b8df0fa199f893df983cb89c3e2c89c7b4 Mon Sep 17 00:00:00 2001 From: Rob Becker Date: Mon, 8 Mar 2021 09:16:08 -0700 Subject: [PATCH] Prep 1.1.0 release --- .github/workflows/dart.yml | 2 +- CHANGELOG.md | 4 + analysis_options.yaml | 163 +------------------------------------ example/main.dart | 4 +- lib/resize_observer.dart | 9 +- pubspec.yaml | 7 +- 6 files changed, 16 insertions(+), 173 deletions(-) diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index 50f806b..93f604e 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -8,7 +8,7 @@ jobs: runs-on: ubuntu-latest container: - image: google/dart:2.12-dev + image: google/dart:2.12 steps: - uses: actions/checkout@v1 diff --git a/CHANGELOG.md b/CHANGELOG.md index eca8014..4cedccc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,7 @@ +## 1.1.0 + +- Stable release w/ null safety for Dart 2.12+ + ## 1.1.0-nullsafety.1 - fix pub score and tweak pub details diff --git a/analysis_options.yaml b/analysis_options.yaml index 47c93b8..108d105 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -1,162 +1 @@ -analyzer: - -# ALL lint rules are included and the ones not in use are commented -# out with a reason. An up to date list of all options is here -# http://dart-lang.github.io/linter/lints/options/options.html -# Descriptions of each rule is here http://dart-lang.github.io/linter/lints/ -# -# To ignore a lint rule on a case by case basic in code just add a comment -# above it like so: // ignore: -# example: // ignore: invalid_assignment, const_initialized_with_non_constant_value -# -# More info about config lint config options is here -# https://www.dartlang.org/guides/language/analysis-options#excluding-lines-within-a-file -linter: - rules: - # Style: Declare method return types. - # override with // ignore: always_declare_return_types - - always_declare_return_types - - # Style: Specify type annotations. - - always_specify_types # really annoying for local vars - - # Style: Annotate overridden members - - annotate_overrides - - # Style: Avoid using as. - - avoid_as - - # Error: Avoid empty else statements. - - avoid_empty_else - - # Style: Don't explicitly initialize variables to null - - avoid_init_to_null - - # Style: Avoid return types on setters. - - avoid_return_types_on_setters - - # Style: Await only futures. - - await_only_futures - - # Style: Name types using UpperCamelCase. - - camel_case_types - - # Error: Cancel instances of dart.async.StreamSubscription. - - cancel_subscriptions - - # Error: Close instances of dart.core.Sink. - - close_sinks - - # Error: Only reference in scope identifiers in doc comments. - - comment_references - - # Style: Prefer using lowerCamelCase for constant names. - - constant_identifier_names - - # Error: Avoid control flow in finally block. - - control_flow_in_finally - - # Style: Avoid empty catch blocks. - - empty_catches - - # Style: Use ; instead of {} for empty constructor bodies. - - empty_constructor_bodies - - # Error: Avoid empty statements. - - empty_statements - - # Error: Always override hashCode if overriding == - - hash_and_equals - - # Style: Don't import implementation files from another package. - - implementation_imports - - # Error: Conditions should not unconditionally evaluate to "TRUE" or to "FALSE" - - invariant_booleans - - # Error: Invocation of Iterable.contains with references of unrelated types. - - iterable_contains_unrelated_type - - # Style: Name libraries and source files using lowercase_with_underscores. - - library_names - - # Style: Use lowercase_with_underscores when specifying a library prefix. - - library_prefixes - - # Error: Invocation of List.remove with references of unrelated types. - - list_remove_unrelated_type - - # Error: Conditions should not unconditionally evaluate to "TRUE" or to "FALSE" - - literal_only_boolean_expressions - - # Style: Name non-constant identifiers using lowerCamelCase. - - non_constant_identifier_names # UiFactories will lint - - # Style: Avoid defining a one-member abstract class when a simple function will do. - - one_member_abstracts - - # Style: Only throw instances of classes extending either Exception or Error - - only_throw_errors - - # Style: Do not override fields. - - overridden_fields - - # Style: Provide doc comments for all public APIs - - package_api_docs - - # Pub: Use lowercase_with_underscores for package names. - - package_names - - # Style: Prefix library names with the package name and a dot-separated path. - - package_prefixed_library_names - - # Style: Don't reassign references to parameters of functions or methods. - - parameter_assignments - - # Style: Private field could be final. - - prefer_final_fields - - # Style: Prefer final for variable declaration if reference is not reassigned. - # - prefer_final_locals # Noisy, people use var a lot - - # Style: Use isNotEmpty for Iterables and Maps. - - prefer_is_not_empty - - # Style: Document all public members - - public_member_api_docs - - # Style: Prefer to use /// for doc comments - - slash_for_doc_comments - - # Style: Sort constructor declarations before method declarations. - - sort_constructors_first - - # Style: Sort unnamed constructor declarations first - - sort_unnamed_constructors_first - - # Error: Test type arguments in operator ==(Object other). - - test_types_in_equals - - # Error: Avoid throw in finally block. - - throw_in_finally - - # Style: Type annotate public APIs. - - type_annotate_public_apis # render can return either ReactElement or false - - # Style: Don't type annotate initializing formals. - - type_init_formals - - # Style: Await for future expression statements inside async function bodies. - - unawaited_futures - - # Style: Avoid using braces in interpolation when not needed. - # - unnecessary_brace_in_string_interp # preference - - # Style: Avoid wrapping fields in getters and setters just to be "safe". - - unnecessary_getters_setters - - # Error: Equality operator (==) invocation with references of unrelated types. - - unrelated_type_equality_checks - - # Error: Use valid regular expression syntax. - - valid_regexps +include: package:pedantic/analysis_options.yaml diff --git a/example/main.dart b/example/main.dart index 53584d4..14a901c 100644 --- a/example/main.dart +++ b/example/main.dart @@ -6,8 +6,8 @@ import 'package:resize_observer/resize_observer.dart' as ro; bool observing = true; Future main() async { - Element textarea = document.getElementById('textarea')!; - Element obsEl = document.getElementById('observing')!; + final textarea = document.getElementById('textarea')!; + final obsEl = document.getElementById('observing')!; ro.ResizeObserver.observe(textarea, _onResize); obsEl.innerHtml = observing.toString(); diff --git a/lib/resize_observer.dart b/lib/resize_observer.dart index 3f8c202..536d9dc 100644 --- a/lib/resize_observer.dart +++ b/lib/resize_observer.dart @@ -2,8 +2,8 @@ import 'dart:html'; import 'dart:js'; /// A callback for ResizeObserver must conform to this signature -typedef void ResizeObserverCallback(Element element, num x, num y, num width, - num height, num top, num bottom, num left, num right); +typedef ResizeObserverCallback = void Function(Element element, num x, num y, + num width, num height, num top, num bottom, num left, num right); /// Resize Observer abstract class ResizeObserver { @@ -17,8 +17,7 @@ abstract class ResizeObserver { static JsObject? _initResizeObserver() { if (supported) { - return JsObject( - context['ResizeObserver'], [_dispatchResizes]); + return JsObject(context['ResizeObserver'], [_dispatchResizes]); } return null; } @@ -34,7 +33,7 @@ abstract class ResizeObserver { return; } - ResizeObserverCallback? callback = _callbackMap[target!]; + var callback = _callbackMap[target!]; if (callback != null) { JsObject? rect = entry['contentRect']; if (rect != null) { diff --git a/pubspec.yaml b/pubspec.yaml index ef4d2a0..eb11959 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,11 +1,12 @@ name: resize_observer -version: 1.1.0-nullsafety.1 -description: A Dart wrapper for the ResizeObserver API +version: 1.1.0 +description: A Dart wrapper for the ResizeObserver API that uses JS interop and a single observer homepage: https://github.com/robrbecker/resize_observer environment: - sdk: '>=2.12.0-0 <3.0.0' + sdk: '>=2.12.0 <3.0.0' dev_dependencies: + pedantic: build_runner: build_web_compilers: