diff --git a/.fvm/fvm_config.json b/.fvm/fvm_config.json index 6be174a..7bfad02 100644 --- a/.fvm/fvm_config.json +++ b/.fvm/fvm_config.json @@ -1,3 +1,3 @@ { - "flutterSdkVersion": "3.19.4" + "flutterSdkVersion": "3.24.0" } \ No newline at end of file diff --git a/.fvmrc b/.fvmrc index 764b061..262e5e8 100644 --- a/.fvmrc +++ b/.fvmrc @@ -1,3 +1,3 @@ { - "flutter": "3.19.4" + "flutter": "3.24.0" } \ No newline at end of file diff --git a/.github/workflows/netglade_analysis-test.yaml b/.github/workflows/ci.yaml similarity index 50% rename from .github/workflows/netglade_analysis-test.yaml rename to .github/workflows/ci.yaml index 109a5aa..5213a44 100644 --- a/.github/workflows/netglade_analysis-test.yaml +++ b/.github/workflows/ci.yaml @@ -1,45 +1,44 @@ -name: netglade_analysis test +name: CI on: push: branches: - main - tags-ignore: - - 'netglade_analysis-v*' - paths: - - 'packages/netglade_analysis/**' pull_request: - branches: - - main - paths: - - 'packages/netglade_analysis/**' + workflow_dispatch: jobs: test: runs-on: ubuntu-latest strategy: fail-fast: false - defaults: - run: - working-directory: packages/netglade_analysis steps: - uses: actions/checkout@v4 - - uses: dart-lang/setup-dart@v1 - - name: Install Dependencies - run: dart pub get + - name: Configure FVM + uses: kuhnroyal/flutter-fvm-config-action@v2 + id: fvm-config-action + - name: Setup Flutter and Dart + uses: subosito/flutter-action@v2 + with: + flutter-version: ${{ steps.fvm-config-action.outputs.FLUTTER_VERSION }} + channel: ${{ steps.fvm-config-action.outputs.FLUTTER_CHANNEL }} + + - name: Setup Melos + uses: bluefireteam/melos-action@v2 - name: Format run: dart format --line-length 120 --set-exit-if-changed . - - name: Analyze - run: dart analyze . + - name: Dart Analyze + run: melos run lint:dart - name: Install DCM uses: CQLabs/setup-dcm@v1 with: github_token: ${{ secrets.GITHUB_TOKEN }} + version: 1.21.1 - name: Run DCM uses: CQLabs/dcm-action@v1 @@ -52,5 +51,8 @@ jobs: fatal_performance: true fatal_warnings: true - - name: Dry Publish - run: dart pub publish --dry-run + - name: Test + run: melos run test + + - name: Dry Publish Packages + run: melos publish --dry-run -y diff --git a/.github/workflows/netglade_flutter_utils-test.yaml b/.github/workflows/netglade_flutter_utils-test.yaml deleted file mode 100644 index e9b1051..0000000 --- a/.github/workflows/netglade_flutter_utils-test.yaml +++ /dev/null @@ -1,56 +0,0 @@ -name: netglade_flutter_utils test - -on: - push: - branches: - - main - tags-ignore: - - 'netglade_flutter_utils-v*' - paths: - - 'packages/netglade_flutter_utils/**' - pull_request: - branches: - - main - paths: - - 'packages/netglade_flutter_utils/**' - -jobs: - test: - runs-on: ubuntu-latest - strategy: - fail-fast: false - defaults: - run: - working-directory: packages/netglade_flutter_utils - - steps: - - uses: actions/checkout@v4 - - uses: subosito/flutter-action@v2.16.0 - - - name: Install Dependencies - run: flutter pub get - - - name: Format - run: dart format --line-length 120 --set-exit-if-changed . - - - name: Analyze - run: flutter analyze --no-pub --fatal-infos --fatal-warnings - - - name: Install DCM - uses: CQLabs/setup-dcm@v1 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - - - name: Run DCM - uses: CQLabs/dcm-action@v1 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - ci_key: ${{ secrets.DCM_KEY }} - email: ${{ secrets.DCM_EMAIL }} - folders: packages/netglade_flutter_utils - fatal_style: true - fatal_performance: true - fatal_warnings: true - - - name: Dry Publish - run: dart pub publish --dry-run diff --git a/.github/workflows/netglade_utils-test.yaml b/.github/workflows/netglade_utils-test.yaml deleted file mode 100644 index 9377f1d..0000000 --- a/.github/workflows/netglade_utils-test.yaml +++ /dev/null @@ -1,56 +0,0 @@ -name: netglade_utils test - -on: - push: - branches: - - main - tags-ignore: - - 'netglade_utils-v*' - paths: - - 'packages/netglade_utils/**' - pull_request: - branches: - - main - paths: - - 'packages/netglade_utils/**' - -jobs: - test: - runs-on: ubuntu-latest - strategy: - fail-fast: false - defaults: - run: - working-directory: packages/netglade_utils - - steps: - - uses: actions/checkout@v4 - - uses: dart-lang/setup-dart@v1 - - - name: Install Dependencies - run: dart pub get - - - name: Format - run: dart format --line-length 120 --set-exit-if-changed . - - - name: Dart Analyze - run: dart analyze . - - - name: Install DCM - uses: CQLabs/setup-dcm@v1 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - - - name: Run DCM - uses: CQLabs/dcm-action@v1 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - ci_key: ${{ secrets.DCM_KEY }} - email: ${{ secrets.DCM_EMAIL }} - folders: packages/netglade_utils - fatal_style: true - fatal_performance: true - fatal_warnings: true - - - name: Dry Publish - run: dart pub publish --dry-run diff --git a/.vscode/settings.json b/.vscode/settings.json index 2e1f166..3fb11da 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,5 @@ { - "dart.flutterSdkPath": ".fvm/versions/3.19.4", + "dart.flutterSdkPath": ".fvm/versions/3.24.0", "search.exclude": { "**/.fvm": true, "**/*.g.dart": true diff --git a/README.md b/README.md index ce534f4..1964d58 100644 --- a/README.md +++ b/README.md @@ -1,35 +1,32 @@ # NetGlade Flutter Core +[![ci][ci_badge]][ci_badge_link] [![Discord][discord_badge]][discord_badge_link] Dart and Flutter packages used internally at [netglade][netglade_link] -| Package | pub | CI | -| ----------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ | ---------------------------------------------------------------------------------- | -| [netglade_analysis][netglade_analysis-link] | [![netglade_analysis pub.dev badge][netglade_analysis-pub-badge]][netglade_analysis-pub-badge-link] | [![][netglade_analysis-build-badge]][netglade_analysis-build-badge-link] | -| [netglade_utils][netglade_utils-link] | [![netglade_utils pub.dev badge][netglade_utils-pub-badge]][netglade_utils-pub-badge-link] | [![][netglade_utils-build-badge]][netglade_utils-build-badge-link] | -| [netglade_flutter_utils][netglade_flutter_utils-link] | [![netglade_flutter_utils pub.dev badge][netglade_flutter_utils-pub-badge]][netglade_flutter_utils-pub-badge-link] | [![][netglade_flutter_utils-build-badge]][netglade_flutter_utils-build-badge-link] | +| Package | pub | +| ----------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------ | +| [netglade_analysis][netglade_analysis-link] | [![netglade_analysis pub.dev badge][netglade_analysis-pub-badge]][netglade_analysis-pub-badge-link] | +| [netglade_utils][netglade_utils-link] | [![netglade_utils pub.dev badge][netglade_utils-pub-badge]][netglade_utils-pub-badge-link] | +| [netglade_flutter_utils][netglade_flutter_utils-link] | [![netglade_flutter_utils pub.dev badge][netglade_flutter_utils-pub-badge]][netglade_flutter_utils-pub-badge-link] | [netglade_link]: https://netglade.com/en [discord_badge]: https://img.shields.io/discord/1091460081054400532.svg?logo=discord&color=blue [discord_badge_link]: https://discord.gg/sJfBBuDZy4 +[ci_badge]: https://img.shields.io/github/actions/workflow/status/netglade/flutter_core/ci.yaml?branch=main +[ci_badge_link]: https://github.com/netglade/flutter_core/actions/workflows/ci.yaml [netglade_analysis-link]: packages/netglade_analysis [netglade_analysis-pub-badge]: https://img.shields.io/pub/v/netglade_analysis.svg [netglade_analysis-pub-badge-link]: https://pub.dartlang.org/packages/netglade_analysis -[netglade_analysis-build-badge]: https://img.shields.io/github/actions/workflow/status/netglade/flutter_core/netglade_analysis-test.yaml?branch=main -[netglade_analysis-build-badge-link]: https://github.com/netglade/flutter_core/actions/workflows/netglade_utils-test.yaml [netglade_utils-link]: packages/netglade_utils [netglade_utils-pub-badge]: https://img.shields.io/pub/v/netglade_utils.svg [netglade_utils-pub-badge-link]: https://pub.dartlang.org/packages/netglade_utils -[netglade_utils-build-badge]: https://img.shields.io/github/actions/workflow/status/netglade/flutter_core/netglade_utils-test.yaml?branch=main -[netglade_utils-build-badge-link]: https://github.com/netglade/flutter_core/actions/workflows/netglade_utils-test.yaml [netglade_flutter_utils-link]: packages/netglade_flutter_utils [netglade_flutter_utils-pub-badge]: https://img.shields.io/pub/v/netglade_flutter_utils.svg [netglade_flutter_utils-pub-badge-link]: https://pub.dartlang.org/packages/netglade_flutter_utils -[netglade_flutter_utils-build-badge]: https://img.shields.io/github/actions/workflow/status/netglade/flutter_core/netglade_flutter_utils-test.yaml?branch=main -[netglade_flutter_utils-build-badge-link]: https://github.com/netglade/flutter_core/actions/workflows/netglade_utils-test.yaml diff --git a/dcm_global.yaml b/dcm_global.yaml new file mode 100644 index 0000000..d143f9e --- /dev/null +++ b/dcm_global.yaml @@ -0,0 +1 @@ +version: "1.21.1" diff --git a/melos.yaml b/melos.yaml index 14e8acc..45f62a6 100644 --- a/melos.yaml +++ b/melos.yaml @@ -26,12 +26,6 @@ scripts: dirExists: - test - publishable: - run: melos exec -- dart pub publish --dry-run - description: Checks whether packages are publishable. - packageFilters: - scope: "*" - # CLEAN clean: diff --git a/packages/netglade_analysis/CHANGELOG.md b/packages/netglade_analysis/CHANGELOG.md index 3252ae0..f0afad1 100644 --- a/packages/netglade_analysis/CHANGELOG.md +++ b/packages/netglade_analysis/CHANGELOG.md @@ -1,3 +1,22 @@ +## 12.0.0 +- Minimal Dart 3.5.0 +- Adhere to DCM 1.18.0, 1.19.0, and 1.21.0: + - Add avoid-only-rethrow + - Add avoid-returning-cascades + - Add avoid-unsafe-reduce + - Add handle-throwing-invocations + - Add prefer-abstract-final-static-class + - Add avoid-incorrect-image-opacity + - Add avoid-calling-notifier-members-inside-build + - Add avoid-notifier-constructors + - Add dispose-provided-instances + - Add use-ref-read-synchronously +- Adhere to Dart 3.5 and previous lints: + - Add invalid_runtime_check_with_js_interop_types + - Add missing_code_block_language_in_doc_comment + - Add unintended_html_in_doc_comment + - Add unnecessary_library_name + ## 11.0.0 - Adhere to DCM 1.17.0: - Add avoid-collection-equality-checks diff --git a/packages/netglade_analysis/README.md b/packages/netglade_analysis/README.md index 3978d7b..b46910c 100644 --- a/packages/netglade_analysis/README.md +++ b/packages/netglade_analysis/README.md @@ -67,8 +67,8 @@ To indicate your project is using `netglade_analysis` → [discord_badge]: https://img.shields.io/discord/1091460081054400532.svg?logo=discord&color=blue [discord_badge_link]: https://discord.gg/sJfBBuDZy4 -[ci_badge]: https://img.shields.io/github/actions/workflow/status/netglade/flutter_core/netglade_analysis-test.yaml?branch=main -[ci_badge_link]: https://github.com/netglade/flutter_core/actions/workflows/netglade_analysis-test.yaml +[ci_badge]: https://img.shields.io/github/actions/workflow/status/netglade/flutter_core/ci.yaml?branch=main +[ci_badge_link]: https://github.com/netglade/flutter_core/actions/workflows/ci.yaml [pub_badge]: https://img.shields.io/pub/v/netglade_analysis.svg [pub_badge_link]: https://pub.dartlang.org/packages/netglade_analysis diff --git a/packages/netglade_analysis/lib/dcm.yaml b/packages/netglade_analysis/lib/dcm.yaml index 26bef62..ec85347 100644 --- a/packages/netglade_analysis/lib/dcm.yaml +++ b/packages/netglade_analysis/lib/dcm.yaml @@ -1,4 +1,4 @@ -# version 1.17.0 - https://dcm.dev/changelog +# version 1.21.0 - https://dcm.dev/changelog dart_code_metrics: rules: ### Common @@ -9,6 +9,7 @@ dart_code_metrics: # - avoid-banned-annotations # * OK, we just don't have global config # - avoid-banned-file-names # * OK, we just don't have global config # - avoid-banned-imports # * OK, we just don't have global config + # - avoid-banned-names # * OK, we just don't have global config # - avoid-banned-types # * OK, we just don't have global config # - avoid-barrel-files # for now we use them - avoid-bottom-type-in-patterns @@ -94,6 +95,7 @@ dart_code_metrics: - avoid-nullable-parameters-with-default-values - avoid-nullable-tostring - avoid-one-field-records + - avoid-only-rethrow - avoid-passing-async-when-sync-expected: exclude: - test/** @@ -107,6 +109,7 @@ dart_code_metrics: - avoid-redundant-pragma-inline - avoid-referencing-discarded-variables - avoid-renaming-representation-getters + - avoid-returning-cascades - avoid-returning-void - avoid-self-assignment - avoid-self-compare @@ -118,6 +121,7 @@ dart_code_metrics: # - avoid-similar-names # way too pedantic - avoid-slow-collection-methods - avoid-substring + - avoid-suspicious-super-overrides - avoid-throw-in-catch-block - avoid-throw-objects-without-tostring - avoid-top-level-members-in-tests @@ -143,6 +147,7 @@ dart_code_metrics: - avoid-unrelated-type-assertions - avoid-unrelated-type-casts - avoid-unsafe-collection-methods + - avoid-unsafe-reduce - avoid-unused-after-null-check - avoid-unused-generics - avoid-unused-instances @@ -152,6 +157,7 @@ dart_code_metrics: - prefer-switch-with-sealed-classes # - banned-usage # * OK, we just don't have global config - binary-expression-operand-order + - dispose-class-fields - double-literal-format - enum-constants-ordering - format-comment: @@ -160,6 +166,7 @@ dart_code_metrics: - function-always-returns-null: ignored-invocations: - useEffect + - handle-throwing-invocations - map-keys-ordering: exclude: - test/** @@ -199,6 +206,7 @@ dart_code_metrics: - move-variable-closer-to-its-usage - move-variable-outside-iteration - newline-before-case + - newline-before-method - newline-before-return - no-boolean-literal-compare: allow-false: true # allows `variable == false` instead of just `!variable` @@ -224,9 +232,11 @@ dart_code_metrics: #- no-magic-string # way too strict for default values of parameters etc. - no-object-declaration # - parameters-ordering # way too strict + - prefer-abstract-final-static-class # - prefer-addition-subtraction-assignments # dunno - prefer-any-or-every - prefer-async-await + - prefer-boolean-prefixes - prefer-both-inlining-annotations - prefer-bytes-builder - prefer-commenting-analyzer-ignores @@ -245,6 +255,7 @@ dart_code_metrics: - prefer-correct-switch-length: max-length: 20 # default value 10 is sometimes way too much - prefer-correct-test-file-name + # - prefer-correct-throws # for now hard to maintain - prefer-correct-type-name - prefer-declaring-const-constructor - prefer-early-return @@ -252,6 +263,7 @@ dart_code_metrics: - prefer-explicit-function-type - prefer-explicit-parameter-names # - prefer-explicit-type-arguments # inference is better + # - prefer-extracting-function-callbacks # not now - prefer-first # - prefer-getter-over-method # way too pedantic - prefer-immediate-return @@ -266,6 +278,8 @@ dart_code_metrics: - test/** - prefer-named-boolean-parameters # - prefer-named-imports # * OK, we just don't have global config + - prefer-named-parameters: # TODO + max-number: 2 - prefer-null-aware-spread - prefer-overriding-parent-equality - prefer-parentheses-with-if-null @@ -296,6 +310,7 @@ dart_code_metrics: exclude: - test/** # - avoid-missing-test-files # * OK, but should be enabled per project + - avoid-misused-set-literals - avoid-misused-test-matchers - prefer-wildcard-pattern # - tag-name # * OK, we just don't have global config @@ -309,6 +324,7 @@ dart_code_metrics: - avoid-empty-setstate - avoid-expanded-as-spacer - avoid-incomplete-copy-with + - avoid-incorrect-image-opacity - avoid-inherited-widget-in-initstate - avoid-late-context - avoid-missing-controller @@ -360,9 +376,13 @@ dart_code_metrics: - prefer-multi-bloc-provider ### Riverpod + - avoid-calling-notifier-members-inside-build + - avoid-notifier-constructors - avoid-ref-read-inside-build - avoid-ref-watch-outside-build - avoid-unnecessary-consumer-widgets + - dispose-provided-instances + - use-ref-read-synchronously ### Equatable # - extend-equatable # * OK, we just don't have global config @@ -393,6 +413,16 @@ dart_code_metrics: - prefer-use-callback - prefer-use-prefix + ### Firabase Analytics + - incorrect-firebase-event-name + - incorrect-firebase-parameter-name + + ### GetX - not used + # - always-remove-getx-listener + # - avoid-getx-rx-inside-build + # - dispose-getx-fields + # - proper-getx-super-calls + ### Intl - not used # - prefer-date-format # - prefer-intl-name @@ -401,6 +431,9 @@ dart_code_metrics: # - prefer-providing-intl-examples # - provide-correct-intl-args + ### Easy Localization + - avoid-missing-tr + ### Angular - not used # - avoid-preserve-whitespace-false # - component-annotation-arguments-ordering diff --git a/packages/netglade_analysis/lib/lints.yaml b/packages/netglade_analysis/lib/lints.yaml index 153a656..f21388d 100644 --- a/packages/netglade_analysis/lib/lints.yaml +++ b/packages/netglade_analysis/lib/lints.yaml @@ -41,6 +41,7 @@ linter: - hash_and_equals - implicit_reopen - invalid_case_patterns + - invalid_runtime_check_with_js_interop_types - literal_only_boolean_expressions - no_adjacent_strings_in_list - no_duplicate_case_values @@ -107,6 +108,7 @@ linter: - dangling_library_doc_comments - deprecated_consistency - directives_ordering + # - document_ignores # we use DCM for this # - do_not_use_environment - empty_catches - empty_constructor_bodies @@ -124,6 +126,7 @@ linter: - library_private_types_in_public_api # - lines_longer_than_80_chars # we use 120 - matching_super_parameters + - missing_code_block_language_in_doc_comment - missing_whitespace_between_adjacent_strings - no_default_cases - non_constant_identifier_names @@ -193,6 +196,7 @@ linter: - type_init_formals - type_literal_in_constant_pattern - unawaited_futures + - unintended_html_in_doc_comment - unnecessary_await_in_return - unnecessary_brace_in_string_interps - unnecessary_breaks @@ -205,6 +209,7 @@ linter: - unnecessary_getters_setters - unnecessary_lambdas - unnecessary_late + - unnecessary_library_name - unnecessary_nullable_for_final_variable_declarations - unnecessary_null_aware_operator_on_extension_on_nullable - unnecessary_null_checks diff --git a/packages/netglade_analysis/lib/netglade_analysis.dart b/packages/netglade_analysis/lib/netglade_analysis.dart index b3b30a2..c024780 100644 --- a/packages/netglade_analysis/lib/netglade_analysis.dart +++ b/packages/netglade_analysis/lib/netglade_analysis.dart @@ -1,5 +1,5 @@ // ignore_for_file: unused-files /// NetGlade Dart and Flutter analyzer settings and best practices -/// used internally at [netglade](https://netglade.com). -library netglade_analysis; +/// used internally at netglade. +library; diff --git a/packages/netglade_analysis/pubspec.yaml b/packages/netglade_analysis/pubspec.yaml index 1423df3..0352b92 100644 --- a/packages/netglade_analysis/pubspec.yaml +++ b/packages/netglade_analysis/pubspec.yaml @@ -1,5 +1,5 @@ name: netglade_analysis -version: 11.0.0 +version: 12.0.0 description: Lint rules for Dart and Flutter used internally at netglade. repository: https://github.com/netglade/flutter_core/tree/main/packages/netglade_analysis issue_tracker: https://github.com/netglade/flutter_core/issues @@ -10,4 +10,4 @@ screenshots: path: doc/icon.png environment: - sdk: ">=2.18.0 <4.0.0" + sdk: ^3.5.0 diff --git a/packages/netglade_flutter_utils/CHANGELOG.md b/packages/netglade_flutter_utils/CHANGELOG.md index 06b26d7..a1a1fa5 100644 --- a/packages/netglade_flutter_utils/CHANGELOG.md +++ b/packages/netglade_flutter_utils/CHANGELOG.md @@ -1,2 +1,5 @@ +## 1.0.1 +- Adhere to `netglade_analysis 12.0.0`. + ## 1.0.0 - Initial release. diff --git a/packages/netglade_flutter_utils/README.md b/packages/netglade_flutter_utils/README.md index 1a61187..6ce1f55 100644 --- a/packages/netglade_flutter_utils/README.md +++ b/packages/netglade_flutter_utils/README.md @@ -18,8 +18,8 @@ Flutter utils used internally at [netglade][netglade_link]. [discord_badge]: https://img.shields.io/discord/1091460081054400532.svg?logo=discord&color=blue [discord_badge_link]: https://discord.gg/sJfBBuDZy4 -[ci_badge]: https://img.shields.io/github/actions/workflow/status/netglade/flutter_core/netglade_flutter_utils-test.yaml?branch=main -[ci_badge_link]: https://github.com/netglade/flutter_core/actions/workflows/netglade_flutter_utils-test.yaml +[ci_badge]: https://img.shields.io/github/actions/workflow/status/netglade/flutter_core/ci.yaml?branch=main +[ci_badge_link]: https://github.com/netglade/flutter_core/actions/workflows/ci.yaml [pub_badge]: https://img.shields.io/pub/v/netglade_flutter_utils.svg [pub_badge_link]: https://pub.dartlang.org/packages/netglade_flutter_utils diff --git a/packages/netglade_flutter_utils/lib/netglade_flutter_utils.dart b/packages/netglade_flutter_utils/lib/netglade_flutter_utils.dart index 8c0dbd6..7a44511 100644 --- a/packages/netglade_flutter_utils/lib/netglade_flutter_utils.dart +++ b/packages/netglade_flutter_utils/lib/netglade_flutter_utils.dart @@ -1,6 +1,6 @@ /// NetGlade Flutter utils library -/// used internally at [netglade](https://netglade.com). -library netglade_flutter_utils; +/// used internally at netglade. +library; export 'src/conditionals/conditionals.dart'; export 'src/extensions/extensions.dart'; diff --git a/packages/netglade_flutter_utils/lib/src/conditionals/conditional.dart b/packages/netglade_flutter_utils/lib/src/conditionals/conditional.dart index 44239dd..bc49486 100644 --- a/packages/netglade_flutter_utils/lib/src/conditionals/conditional.dart +++ b/packages/netglade_flutter_utils/lib/src/conditionals/conditional.dart @@ -5,6 +5,7 @@ import 'package:flutter/material.dart'; /// Based on [condition] builds either [whenTrue] on true or [whenFalse] on false. /// If no [whenFalse] is specified, `SizedBox.shrink()` is used. class Conditional extends StatelessWidget { + // ignore: prefer-boolean-prefixes, dont wannta change public API final bool condition; // ignore: prefer-correct-callback-field-name, this is more suited diff --git a/packages/netglade_flutter_utils/lib/src/conditionals/conditional_child.dart b/packages/netglade_flutter_utils/lib/src/conditionals/conditional_child.dart index 63b806d..9bf16a6 100644 --- a/packages/netglade_flutter_utils/lib/src/conditionals/conditional_child.dart +++ b/packages/netglade_flutter_utils/lib/src/conditionals/conditional_child.dart @@ -6,6 +6,7 @@ typedef WidgetWithChildBuilder = Widget Function(BuildContext context, Widget ch /// Based on [condition] builds either [whenTrue] on true or [whenFalse] on false and wraps [child] widget. /// If no [whenFalse] is specified, `SizedBox.shrink()` is used. class ConditionalChild extends StatelessWidget { + // ignore: prefer-boolean-prefixes, dont wannta change public API final bool condition; // ignore: prefer-correct-callback-field-name, this is more suited diff --git a/packages/netglade_flutter_utils/lib/src/conditionals/conditional_wrap.dart b/packages/netglade_flutter_utils/lib/src/conditionals/conditional_wrap.dart index 9a66af8..ebac24d 100644 --- a/packages/netglade_flutter_utils/lib/src/conditionals/conditional_wrap.dart +++ b/packages/netglade_flutter_utils/lib/src/conditionals/conditional_wrap.dart @@ -5,6 +5,7 @@ typedef WrapperBuilder = Widget Function(BuildContext context, Widget child); /// Wraps [child] child in [wrapper] widget only if [condition] is true. class ConditionalWrap extends StatelessWidget { + // ignore: prefer-boolean-prefixes, dont wannta change public API final bool condition; // ignore: prefer-correct-callback-field-name, this is more suited diff --git a/packages/netglade_flutter_utils/lib/src/extensions/text_style_extensions.dart b/packages/netglade_flutter_utils/lib/src/extensions/text_style_extensions.dart index 874ca8b..a232b90 100644 --- a/packages/netglade_flutter_utils/lib/src/extensions/text_style_extensions.dart +++ b/packages/netglade_flutter_utils/lib/src/extensions/text_style_extensions.dart @@ -10,8 +10,12 @@ extension TextStyleExtensions on TextStyle { TextStyle get italic => copyWith(fontStyle: FontStyle.italic); TextStyle withLetterSpacing(double value) => copyWith(letterSpacing: value); + TextStyle withLineHeight(double value) => copyWith(height: value); + TextStyle withColor(Color? value) => color != null ? copyWith(color: value) : this; + TextStyle withWeight(FontWeight value) => copyWith(fontWeight: value); + TextStyle withSize(double size) => copyWith(fontSize: size); } diff --git a/packages/netglade_flutter_utils/lib/src/hooks/on_page_is_visible.dart b/packages/netglade_flutter_utils/lib/src/hooks/on_page_is_visible.dart index 22db62e..5f7ad5f 100644 --- a/packages/netglade_flutter_utils/lib/src/hooks/on_page_is_visible.dart +++ b/packages/netglade_flutter_utils/lib/src/hooks/on_page_is_visible.dart @@ -1,6 +1,7 @@ import 'package:flutter/material.dart'; import 'package:netglade_flutter_utils/src/hooks/route_aware.dart'; +// ignore: prefer-boolean-prefixes, dont wannta change public API typedef OnPageVisibleCallback = void Function({bool pushedIn}); /// Callback [onPageVisible] called when current PageRoute is visible again. diff --git a/packages/netglade_flutter_utils/pubspec.yaml b/packages/netglade_flutter_utils/pubspec.yaml index 2c3ed4f..2e0213e 100644 --- a/packages/netglade_flutter_utils/pubspec.yaml +++ b/packages/netglade_flutter_utils/pubspec.yaml @@ -1,5 +1,5 @@ name: netglade_flutter_utils -version: 1.0.0 +version: 1.0.1 description: Flutter utils used internally at netglade. repository: https://github.com/netglade/flutter_core/tree/main/packages/netglade_flutter_utils issue_tracker: https://github.com/netglade/flutter_core/issues @@ -7,8 +7,8 @@ homepage: https://github.com/netglade/flutter_core documentation: https://github.com/netglade/flutter_core/tree/main/packages/netglade_flutter_utils environment: - sdk: ^3.0.0 - flutter: ">=3.0.0" + sdk: ^3.5.0 + flutter: ">=3.24.0" dependencies: flutter: @@ -19,7 +19,7 @@ dev_dependencies: flutter_test: sdk: flutter mocktail: ^1.0.0 - netglade_analysis: ^10.0.0 + netglade_analysis: ^12.0.0 test: ^1.24.6 flutter: diff --git a/packages/netglade_utils/CHANGELOG.md b/packages/netglade_utils/CHANGELOG.md index 2a01387..fefa51b 100644 --- a/packages/netglade_utils/CHANGELOG.md +++ b/packages/netglade_utils/CHANGELOG.md @@ -1,3 +1,6 @@ +## 2.4.1 +- Fix `firstLetterUppercase()` for empty strings. +- Adhere to `netglade_analysis 12.0.0`. ## 2.4.0 - Add `standartProLong` future extension. diff --git a/packages/netglade_utils/README.md b/packages/netglade_utils/README.md index 5dd0447..f89383a 100644 --- a/packages/netglade_utils/README.md +++ b/packages/netglade_utils/README.md @@ -18,8 +18,8 @@ Dart utils used internally at [netglade][netglade_link]. [discord_badge]: https://img.shields.io/discord/1091460081054400532.svg?logo=discord&color=blue [discord_badge_link]: https://discord.gg/sJfBBuDZy4 -[ci_badge]: https://img.shields.io/github/actions/workflow/status/netglade/flutter_core/netglade_utils-test.yaml?branch=main -[ci_badge_link]: https://github.com/netglade/flutter_core/actions/workflows/netglade_utils-test.yaml +[ci_badge]: https://img.shields.io/github/actions/workflow/status/netglade/flutter_core/ci.yaml?branch=main +[ci_badge_link]: https://github.com/netglade/flutter_core/actions/workflows/ci.yaml [pub_badge]: https://img.shields.io/pub/v/netglade_utils.svg [pub_badge_link]: https://pub.dartlang.org/packages/netglade_utils diff --git a/packages/netglade_utils/lib/netglade_utils.dart b/packages/netglade_utils/lib/netglade_utils.dart index 53f7328..f680ea9 100644 --- a/packages/netglade_utils/lib/netglade_utils.dart +++ b/packages/netglade_utils/lib/netglade_utils.dart @@ -1,6 +1,6 @@ /// NetGlade Dart utils library -/// used internally at [netglade](https://netglade.com). -library netglade_utils; +/// used internally at netglade. +library; export 'src/copy/copy.dart'; export 'src/extensions/extensions.dart'; diff --git a/packages/netglade_utils/lib/src/extensions/date_time_extensions.dart b/packages/netglade_utils/lib/src/extensions/date_time_extensions.dart index 7a64239..bbb91c6 100644 --- a/packages/netglade_utils/lib/src/extensions/date_time_extensions.dart +++ b/packages/netglade_utils/lib/src/extensions/date_time_extensions.dart @@ -43,6 +43,7 @@ extension DateTimeExtensions on DateTime { DateTime get onlyTime => DateTime(1900, 0, 0, hour, minute); /// Returns true if this is before or is the same as [other]. + // ignore: prefer-boolean-prefixes, dont wannta change public API bool isBeforeOrSame(DateTime other, {bool includeTime = false}) { if (includeTime) { return isBefore(other) || this == other; @@ -52,6 +53,7 @@ extension DateTimeExtensions on DateTime { } /// Returns true if this is after os is the same as [other]. + // ignore: prefer-boolean-prefixes, dont wannta change public API bool isAfterOrSame(DateTime other, {bool includeTime = false}) { return other.isBeforeOrSame(this, includeTime: includeTime); } @@ -69,6 +71,7 @@ extension DateTimeExtensions on DateTime { } } +// ignore: prefer-single-declaration-per-file, this can be here enum DateSpecification { endOfWeek, nextWeek, diff --git a/packages/netglade_utils/lib/src/extensions/future_extensions.dart b/packages/netglade_utils/lib/src/extensions/future_extensions.dart index 22e8859..09077d9 100644 --- a/packages/netglade_utils/lib/src/extensions/future_extensions.dart +++ b/packages/netglade_utils/lib/src/extensions/future_extensions.dart @@ -7,8 +7,7 @@ typedef OnTakingTooLongCallback = void Function(); extension FutureExtensions on Future { static const standardProlongTimeMs = 300; - // ignore: comment_references, see https://github.com/dart-lang/linter/issues/2079 - /// If [this] future taking longer than [duration] to execute - [callback] is called. + /// If `this` future taking longer than [duration] to execute - [callback] is called. Future onTakingTooLong( Duration duration, OnTakingTooLongCallback callback, diff --git a/packages/netglade_utils/lib/src/extensions/iterable_extensions.dart b/packages/netglade_utils/lib/src/extensions/iterable_extensions.dart index e0ed7f2..4403b06 100644 --- a/packages/netglade_utils/lib/src/extensions/iterable_extensions.dart +++ b/packages/netglade_utils/lib/src/extensions/iterable_extensions.dart @@ -21,6 +21,7 @@ extension IterableExtensions on Iterable { Iterable mapIndexed2(K Function(int index, T value) map) => indexed.map((entry) => map(entry.$1, entry.$2)); } +// ignore: prefer-single-declaration-per-file, this can be here extension IterableIterableExtension on Iterable> { List get flattenedList => [for (final elements in this) ...elements]; } diff --git a/packages/netglade_utils/lib/src/extensions/string_extensions.dart b/packages/netglade_utils/lib/src/extensions/string_extensions.dart index 40143ea..2bfbe51 100644 --- a/packages/netglade_utils/lib/src/extensions/string_extensions.dart +++ b/packages/netglade_utils/lib/src/extensions/string_extensions.dart @@ -80,6 +80,7 @@ extension StringExtensions on String { } } +// ignore: prefer-single-declaration-per-file, this can be here extension NullableStringExtensions on String? { /// Returns true when `this` is either `null` or `isBlank`. /// diff --git a/packages/netglade_utils/lib/src/result/option.dart b/packages/netglade_utils/lib/src/result/option.dart index 4472968..f508121 100644 --- a/packages/netglade_utils/lib/src/result/option.dart +++ b/packages/netglade_utils/lib/src/result/option.dart @@ -87,6 +87,7 @@ final class Some extends Option { some(value); } +// ignore: prefer-single-declaration-per-file, this can be here extension OptionExtension on Option { // ignore: avoid-non-null-assertion, developer's responsbility T get asSome => mapOrNull(some: (r) => r)!.value; diff --git a/packages/netglade_utils/lib/src/result/result_impl.dart b/packages/netglade_utils/lib/src/result/result_impl.dart index 94e97f3..c68745d 100644 --- a/packages/netglade_utils/lib/src/result/result_impl.dart +++ b/packages/netglade_utils/lib/src/result/result_impl.dart @@ -86,6 +86,7 @@ final class Error extends Result { error(this.error); } +// ignore: prefer-single-declaration-per-file, this can be here extension ResultExtension on Result { bool get isSuccess => this is Success; bool get isError => !isSuccess; diff --git a/packages/netglade_utils/lib/src/testing/mock_extensions.dart b/packages/netglade_utils/lib/src/testing/mock_extensions.dart index e453f8b..f71bef3 100644 --- a/packages/netglade_utils/lib/src/testing/mock_extensions.dart +++ b/packages/netglade_utils/lib/src/testing/mock_extensions.dart @@ -1,4 +1,4 @@ -// ignore_for_file: prefer-match-file-name +// ignore_for_file: prefer-match-file-name, prefer-single-declaration-per-file import 'dart:async'; diff --git a/packages/netglade_utils/pubspec.yaml b/packages/netglade_utils/pubspec.yaml index 3f3a90f..1b75943 100644 --- a/packages/netglade_utils/pubspec.yaml +++ b/packages/netglade_utils/pubspec.yaml @@ -1,5 +1,5 @@ name: netglade_utils -version: 2.4.0 +version: 2.4.1 description: Dart utils used internally at netglade. repository: https://github.com/netglade/flutter_core/tree/main/packages/netglade_utils issue_tracker: https://github.com/netglade/flutter_core/issues @@ -7,7 +7,7 @@ homepage: https://github.com/netglade/flutter_core documentation: https://github.com/netglade/flutter_core/tree/main/packages/netglade_utils environment: - sdk: ^3.0.0 + sdk: ^3.5.0 dependencies: characters: ^1.2.0 @@ -17,5 +17,5 @@ dependencies: mocktail: ^1.0.0 dev_dependencies: - netglade_analysis: ^10.0.0 + netglade_analysis: ^12.0.0 test: ^1.24.6 diff --git a/packages/netglade_utils/test/src/extensions/string_extensions_test.dart b/packages/netglade_utils/test/src/extensions/string_extensions_test.dart index 2327d83..41b0574 100644 --- a/packages/netglade_utils/test/src/extensions/string_extensions_test.dart +++ b/packages/netglade_utils/test/src/extensions/string_extensions_test.dart @@ -281,25 +281,25 @@ void main() { }); }); - group("firstLetterUppercase", () { - test("empty message", () { - final String value = ""; - expect(value.firstLetterUppercase(), equals("")); + group('firstLetterUppercase', () { + test('empty message', () { + final String value = ''; + expect(value.firstLetterUppercase(), equals('')); }); - test("message with whitespaces", () { - final String value = " "; + test('message with whitespaces', () { + final String value = ' '; expect(value.firstLetterUppercase(), equals(value)); }); - test("message with non-whitespace characters", () { - final String value = "xxx"; - expect(value.firstLetterUppercase(), equals("Xxx")); + test('message with non-whitespace characters', () { + final String value = 'xxx'; + expect(value.firstLetterUppercase(), equals('Xxx')); }); - test("message with 1 character", () { - final String value = "x"; - expect(value.firstLetterUppercase(), equals("X")); + test('message with 1 character', () { + final String value = 'x'; + expect(value.firstLetterUppercase(), equals('X')); }); }); });