From 30619a1af1f0daec32d3f396a5c3c295aea1cc15 Mon Sep 17 00:00:00 2001 From: Kevin Moore Date: Sat, 18 May 2024 17:58:33 -0700 Subject: [PATCH] Update dependencies and SDK constraints --- .github/workflows/dart.yml | 64 +++++++++---------- _test_yaml/pubspec.yaml | 14 ++-- checked_yaml/pubspec.yaml | 10 +-- example/pubspec.yaml | 10 +-- json_annotation/pubspec.yaml | 4 +- json_serializable/lib/src/decode_helper.dart | 5 +- json_serializable/lib/src/field_helpers.dart | 4 +- json_serializable/lib/src/helper_core.dart | 2 +- json_serializable/lib/src/json_key_utils.dart | 4 +- .../lib/src/json_serializable_generator.dart | 8 --- .../type_helpers/generic_factory_helper.dart | 5 +- .../lib/src/type_helpers/map_helper.dart | 2 +- json_serializable/lib/src/utils.dart | 8 ++- json_serializable/pubspec.yaml | 32 +++++----- shared_test/pubspec.yaml | 4 +- tool/ci.sh | 18 ++---- 16 files changed, 96 insertions(+), 98 deletions(-) diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index 0be82d568..121296a69 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -1,4 +1,4 @@ -# Created with package:mono_repo v6.5.7 +# Created with package:mono_repo v6.6.1 name: Dart CI on: push: @@ -36,27 +36,27 @@ jobs: name: Checkout repository uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 - name: mono_repo self validate - run: dart pub global activate mono_repo 6.5.7 + run: dart pub global activate mono_repo 6.6.1 - name: mono_repo self validate run: dart pub global run mono_repo generate --validate job_002: - name: "analyzer_and_format; Dart 3.0.0; PKGS: _test_yaml, checked_yaml, example, json_annotation, json_serializable; `dart analyze`" + name: "analyzer_and_format; Dart 3.4.0; PKGS: _test_yaml, checked_yaml, example, json_annotation, json_serializable; `dart analyze`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:_test_yaml-checked_yaml-example-json_annotation-json_serializable;commands:analyze_1" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0;packages:_test_yaml-checked_yaml-example-json_annotation-json_serializable;commands:analyze_1" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:_test_yaml-checked_yaml-example-json_annotation-json_serializable - os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0 + os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0;packages:_test_yaml-checked_yaml-example-json_annotation-json_serializable + os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0 os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: - sdk: "3.0.0" + sdk: "3.4.0" - id: checkout name: Checkout repository uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 @@ -192,23 +192,23 @@ jobs: if: "always() && steps.json_serializable_pub_upgrade.conclusion == 'success'" working-directory: json_serializable job_004: - name: "unit_test; Dart 3.0.0; PKGS: _test_yaml, checked_yaml, example, json_serializable; `dart test`" + name: "unit_test; Dart 3.4.0; PKGS: _test_yaml, checked_yaml, example, json_serializable; `dart test`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:_test_yaml-checked_yaml-example-json_serializable;commands:test_0" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0;packages:_test_yaml-checked_yaml-example-json_serializable;commands:test_0" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:_test_yaml-checked_yaml-example-json_serializable - os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0 + os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0;packages:_test_yaml-checked_yaml-example-json_serializable + os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0 os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: - sdk: "3.0.0" + sdk: "3.4.0" - id: checkout name: Checkout repository uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 @@ -253,23 +253,23 @@ jobs: - job_002 - job_003 job_005: - name: "unit_test; Dart 3.0.0; PKG: json_serializable; `dart test --run-skipped -t presubmit-only test/annotation_version_test.dart`" + name: "unit_test; Dart 3.4.0; PKG: json_serializable; `dart test --run-skipped -t presubmit-only test/annotation_version_test.dart`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:json_serializable;commands:test_3" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0;packages:json_serializable;commands:test_3" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:json_serializable - os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0 + os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0;packages:json_serializable + os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0 os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: - sdk: "3.0.0" + sdk: "3.4.0" - id: checkout name: Checkout repository uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 @@ -287,23 +287,23 @@ jobs: - job_002 - job_003 job_006: - name: "unit_test; Dart 3.0.0; PKG: json_serializable; `dart test --run-skipped -t presubmit-only test/ensure_build_test.dart`" + name: "unit_test; Dart 3.4.0; PKG: json_serializable; `dart test --run-skipped -t presubmit-only test/ensure_build_test.dart`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:json_serializable;commands:test_1" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0;packages:json_serializable;commands:test_1" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:json_serializable - os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0 + os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0;packages:json_serializable + os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0 os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: - sdk: "3.0.0" + sdk: "3.4.0" - id: checkout name: Checkout repository uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 @@ -321,23 +321,23 @@ jobs: - job_002 - job_003 job_007: - name: "unit_test; Dart 3.0.0; PKG: json_serializable; `dart test -p chrome`" + name: "unit_test; Dart 3.4.0; PKG: json_serializable; `dart test -p chrome`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:json_serializable;commands:test_2" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0;packages:json_serializable;commands:test_2" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:json_serializable - os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0 + os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0;packages:json_serializable + os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0 os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: - sdk: "3.0.0" + sdk: "3.4.0" - id: checkout name: Checkout repository uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 @@ -518,23 +518,23 @@ jobs: - job_002 - job_003 job_012: - name: "ensure_build; Dart 3.0.0; PKGS: _test_yaml, checked_yaml, example; `dart test --run-skipped -t presubmit-only test/ensure_build_test.dart`" + name: "ensure_build; Dart 3.4.0; PKGS: _test_yaml, checked_yaml, example; `dart test --run-skipped -t presubmit-only test/ensure_build_test.dart`" runs-on: ubuntu-latest steps: - name: Cache Pub hosted dependencies uses: actions/cache@0c45773b623bea8c8e75f6c82b208c3cf94ea4f9 with: path: "~/.pub-cache/hosted" - key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:_test_yaml-checked_yaml-example;commands:test_1" + key: "os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0;packages:_test_yaml-checked_yaml-example;commands:test_1" restore-keys: | - os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0;packages:_test_yaml-checked_yaml-example - os:ubuntu-latest;pub-cache-hosted;sdk:3.0.0 + os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0;packages:_test_yaml-checked_yaml-example + os:ubuntu-latest;pub-cache-hosted;sdk:3.4.0 os:ubuntu-latest;pub-cache-hosted os:ubuntu-latest - name: Setup Dart SDK uses: dart-lang/setup-dart@fedb1266e91cf51be2fdb382869461a434b920a3 with: - sdk: "3.0.0" + sdk: "3.4.0" - id: checkout name: Checkout repository uses: actions/checkout@9bb56186c3b09b4f86b1c65136769dd318469633 diff --git a/_test_yaml/pubspec.yaml b/_test_yaml/pubspec.yaml index 57f7a275b..8bf18a935 100644 --- a/_test_yaml/pubspec.yaml +++ b/_test_yaml/pubspec.yaml @@ -2,19 +2,19 @@ name: _test_yaml publish_to: none environment: - sdk: ^3.0.0 + sdk: ^3.4.0 dev_dependencies: _json_serial_shared_test: path: ../shared_test - build_runner: ^2.0.0 + build_runner: ^2.2.1 build_verify: ^3.0.0 - checked_yaml: any - dart_flutter_team_lints: ^2.0.0 - json_annotation: ^4.8.1 - json_serializable: any + checked_yaml: ^2.0.4-wip + dart_flutter_team_lints: ^3.0.0 + json_annotation: ^4.9.0 + json_serializable: ^6.8.0 path: ^1.8.2 - test: ^1.6.0 + test: ^1.21.6 yaml: ^3.0.0 dependency_overrides: diff --git a/checked_yaml/pubspec.yaml b/checked_yaml/pubspec.yaml index 821c9de5e..2be93cc62 100644 --- a/checked_yaml/pubspec.yaml +++ b/checked_yaml/pubspec.yaml @@ -13,7 +13,7 @@ topics: - codegen environment: - sdk: ^3.0.0 + sdk: ^3.4.0 dependencies: json_annotation: ^4.3.0 @@ -21,12 +21,12 @@ dependencies: yaml: ^3.0.0 dev_dependencies: - build_runner: ^2.0.0 + build_runner: ^2.0.6 build_verify: ^3.0.0 - dart_flutter_team_lints: ^2.0.0 + dart_flutter_team_lints: ^3.0.0 json_serializable: ^6.0.0 - path: ^1.0.0 - test: ^1.16.0 + path: ^1.8.0 + test: ^1.17.10 test_process: ^2.0.0 #dependency_overrides: diff --git a/example/pubspec.yaml b/example/pubspec.yaml index 6191089bd..be24d38a3 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -2,10 +2,10 @@ name: example publish_to: none environment: - sdk: ^3.0.0 + sdk: ^3.4.0 dependencies: - json_annotation: ^4.8.0 + json_annotation: ^4.9.0 dev_dependencies: # Used by tests. Not required to use `json_serializable`. @@ -19,14 +19,14 @@ dev_dependencies: build_verify: ^3.0.0 # Not required to use `json_serializable`. - dart_flutter_team_lints: ^2.0.0 + dart_flutter_team_lints: ^3.0.0 # REQUIRED! - json_serializable: ^6.6.0 + json_serializable: ^6.8.0 # Not required to use `json_serializable`. path: ^1.8.0 - test: ^1.16.0 + test: ^1.21.6 # This section is used to verify changes to these packages. Do not include in # your code! diff --git a/json_annotation/pubspec.yaml b/json_annotation/pubspec.yaml index 5d748a0e9..96d41d8e9 100644 --- a/json_annotation/pubspec.yaml +++ b/json_annotation/pubspec.yaml @@ -11,13 +11,13 @@ topics: - codegen environment: - sdk: ^3.0.0 + sdk: ^3.4.0 dependencies: meta: ^1.4.0 dev_dependencies: - dart_flutter_team_lints: ^2.0.0 + dart_flutter_team_lints: ^3.0.0 # When changing JsonSerializable class. # build_runner: ^2.0.0 # json_serializable: any diff --git a/json_serializable/lib/src/decode_helper.dart b/json_serializable/lib/src/decode_helper.dart index a4a76d1ff..488e93ef3 100644 --- a/json_serializable/lib/src/decode_helper.dart +++ b/json_serializable/lib/src/decode_helper.dart @@ -61,7 +61,10 @@ mixin DecodeHelper implements HelperCore { config.constructor, accessibleFields.keys, accessibleFields.values - .where((fe) => element.lookUpSetter(fe.name, element.library) != null) + .where((fe) => + element.augmented + .lookUpSetter(name: fe.name, library: element.library) != + null) .map((fe) => fe.name) .toList(), unavailableReasons, diff --git a/json_serializable/lib/src/field_helpers.dart b/json_serializable/lib/src/field_helpers.dart index 4b6608f3f..f0b7828e9 100644 --- a/json_serializable/lib/src/field_helpers.dart +++ b/json_serializable/lib/src/field_helpers.dart @@ -88,8 +88,8 @@ List createSortedFieldSet(ClassElement element) { } if (v is PropertyAccessorElement && v.isGetter) { - assert(v.variable is FieldElement); - final variable = v.variable as FieldElement; + assert(v.variable2 is FieldElement); + final variable = v.variable2 as FieldElement; assert(!inheritedFields.containsKey(variable.name)); inheritedFields[variable.name] = variable; } diff --git a/json_serializable/lib/src/helper_core.dart b/json_serializable/lib/src/helper_core.dart index 5a8248c66..0a054f828 100644 --- a/json_serializable/lib/src/helper_core.dart +++ b/json_serializable/lib/src/helper_core.dart @@ -66,7 +66,7 @@ InvalidGenerationSourceError createInvalidGenerationError( String? todo; if (error.type is TypeParameterType) { message = '$message because of type ' - '`${error.type.getDisplayString(withNullability: false)}` ' + '`${error.type.toStringNonNullable()}` ' '(type parameter)'; todo = ''' diff --git a/json_serializable/lib/src/json_key_utils.dart b/json_serializable/lib/src/json_key_utils.dart index 42eb0cfce..addccaae8 100644 --- a/json_serializable/lib/src/json_key_utils.dart +++ b/json_serializable/lib/src/json_key_utils.dart @@ -176,9 +176,9 @@ KeyConfig _from(FieldElement element, ClassConfig classAnnotation) { throwUnsupported( element, '`$fieldName` has type ' - '`${targetEnumType.getDisplayString(withNullability: false)}`, but ' + '`${targetEnumType.toStringNonNullable()}`, but ' 'the provided unknownEnumValue is of type ' - '`${annotationType.getDisplayString(withNullability: false)}`.', + '`${annotationType.toStringNonNullable()}`.', ); } } diff --git a/json_serializable/lib/src/json_serializable_generator.dart b/json_serializable/lib/src/json_serializable_generator.dart index 611056131..2ff7b6dbf 100644 --- a/json_serializable/lib/src/json_serializable_generator.dart +++ b/json_serializable/lib/src/json_serializable_generator.dart @@ -61,14 +61,6 @@ class JsonSerializableGenerator ConstantReader annotation, BuildStep buildStep, ) { - if (!element.library!.isNonNullableByDefault) { - throw InvalidGenerationSourceError( - 'Generator cannot target libraries that have not been migrated to ' - 'null-safety.', - element: element, - ); - } - if (element is! ClassElement || element is EnumElement) { throw InvalidGenerationSourceError( '`@JsonSerializable` can only be used on classes.', diff --git a/json_serializable/lib/src/type_helpers/generic_factory_helper.dart b/json_serializable/lib/src/type_helpers/generic_factory_helper.dart index 3b807550c..fc8cef843 100644 --- a/json_serializable/lib/src/type_helpers/generic_factory_helper.dart +++ b/json_serializable/lib/src/type_helpers/generic_factory_helper.dart @@ -3,6 +3,7 @@ // BSD-style license that can be found in the LICENSE file. import 'package:analyzer/dart/element/type.dart'; +import 'package:json_serializable/src/utils.dart'; import 'package:source_helper/source_helper.dart'; import '../lambda_result.dart'; @@ -75,11 +76,11 @@ Object? $_toJsonHelperName( '''; String toJsonForType(TypeParameterType type) => - toJsonForName(type.getDisplayString(withNullability: false)); + toJsonForName(type.toStringNonNullable()); String toJsonForName(String genericType) => 'toJson$genericType'; String fromJsonForType(TypeParameterType type) => - fromJsonForName(type.getDisplayString(withNullability: false)); + fromJsonForName(type.toStringNonNullable()); String fromJsonForName(String genericType) => 'fromJson$genericType'; diff --git a/json_serializable/lib/src/type_helpers/map_helper.dart b/json_serializable/lib/src/type_helpers/map_helper.dart index 806c7074e..51cb3a0a5 100644 --- a/json_serializable/lib/src/type_helpers/map_helper.dart +++ b/json_serializable/lib/src/type_helpers/map_helper.dart @@ -94,7 +94,7 @@ class MapHelper extends TypeHelper { // `toDouble` on input values valueArg.isSimpleJsonTypeNotDouble)) { // No mapping of the values or null check required! - final valueString = valueArg.getDisplayString(withNullability: true); + final valueString = valueArg.getDisplayString(); return 'Map.from($expression as Map)'; } } diff --git a/json_serializable/lib/src/utils.dart b/json_serializable/lib/src/utils.dart index 0bf6dba64..782eeb53d 100644 --- a/json_serializable/lib/src/utils.dart +++ b/json_serializable/lib/src/utils.dart @@ -177,6 +177,12 @@ Iterable? iterateEnumFields(DartType targetType) { extension DartTypeExtension on DartType { DartType promoteNonNullable() => element?.library?.typeSystem.promoteToNonNull(this) ?? this; + + String toStringNonNullable() { + final val = getDisplayString(); + if (val.endsWith('?')) return val.substring(0, val.length - 1); + return val; + } } String ifNullOrElse(String test, String ifNull, String ifNotNull) => @@ -216,7 +222,7 @@ String typeToCode( } if (type is TypeParameterType) { - return type.getDisplayString(withNullability: false); + return type.toStringNonNullable(); } throw UnimplementedError('(${type.runtimeType}) $type'); } diff --git a/json_serializable/pubspec.yaml b/json_serializable/pubspec.yaml index e6d66865d..5d7937b3b 100644 --- a/json_serializable/pubspec.yaml +++ b/json_serializable/pubspec.yaml @@ -5,7 +5,7 @@ description: >- Dart classes. repository: https://github.com/google/json_serializable.dart/tree/master/json_serializable environment: - sdk: ^3.0.0 + sdk: ^3.4.0 topics: - json - build-runner @@ -13,32 +13,32 @@ topics: - codegen dependencies: - analyzer: '>=5.12.0 <7.0.0' - async: ^2.8.0 - build: ^2.0.0 - build_config: '>=0.4.4 <2.0.0' - collection: ^1.14.0 + analyzer: ^6.5.0 + async: ^2.10.0 + build: ^2.4.1 + build_config: ^1.1.0 + collection: ^1.17.0 # Use a tight version constraint to ensure that a constraint on # `json_annotation` properly constrains all features it provides. json_annotation: '>=4.9.0 <4.10.0' - meta: ^1.3.0 - path: ^1.8.0 - pub_semver: ^2.0.0 + meta: ^1.14.0 + path: ^1.9.0 + pub_semver: ^2.1.4 pubspec_parse: ^1.0.0 - source_gen: ^1.3.2 - source_helper: ^1.3.0 + source_gen: ^1.4.0 + source_helper: ^1.3.4 dev_dependencies: _json_serial_shared_test: path: ../shared_test - build_runner: ^2.0.0 + build_runner: ^2.4.6 build_verify: ^3.0.0 - dart_flutter_team_lints: ^2.0.0 - dart_style: ^2.0.0 + dart_flutter_team_lints: ^3.0.0 + dart_style: ^2.3.2 logging: ^1.0.0 - source_gen_test: ^1.0.0 - test: ^1.16.0 + source_gen_test: ^1.0.6 + test: ^1.24.4 test_descriptor: ^2.0.0 test_process: ^2.0.0 yaml: ^3.0.0 diff --git a/shared_test/pubspec.yaml b/shared_test/pubspec.yaml index 6cb35af92..975abe375 100644 --- a/shared_test/pubspec.yaml +++ b/shared_test/pubspec.yaml @@ -1,11 +1,11 @@ name: _json_serial_shared_test publish_to: none environment: - sdk: ^3.0.0 + sdk: ^3.4.0 dependencies: stack_trace: ^1.10.0 test: ^1.6.0 dev_dependencies: - dart_flutter_team_lints: ^2.0.0 + dart_flutter_team_lints: ^3.0.0 diff --git a/tool/ci.sh b/tool/ci.sh index 436465312..deac64920 100755 --- a/tool/ci.sh +++ b/tool/ci.sh @@ -1,9 +1,10 @@ #!/bin/bash -# Created with package:mono_repo v6.5.7 +# Created with package:mono_repo v6.6.1 # Support built in commands on windows out of the box. + # When it is a flutter repo (check the pubspec.yaml for "sdk: flutter") -# then "flutter" is called instead of "pub". +# then "flutter pub" is called instead of "dart pub". # This assumes that the Flutter SDK has been installed in a previous step. function pub() { if grep -Fq "sdk: flutter" "${PWD}/pubspec.yaml"; then @@ -12,18 +13,13 @@ function pub() { command dart pub "$@" fi } -# When it is a flutter repo (check the pubspec.yaml for "sdk: flutter") -# then "flutter" is called instead of "pub". -# This assumes that the Flutter SDK has been installed in a previous step. + function format() { - if grep -Fq "sdk: flutter" "${PWD}/pubspec.yaml"; then - command flutter format "$@" - else - command dart format "$@" - fi + command dart format "$@" } + # When it is a flutter repo (check the pubspec.yaml for "sdk: flutter") -# then "flutter" is called instead of "pub". +# then "flutter analyze" is called instead of "dart analyze". # This assumes that the Flutter SDK has been installed in a previous step. function analyze() { if grep -Fq "sdk: flutter" "${PWD}/pubspec.yaml"; then