From 6cb66fc7fd6ba511662a5ab2560331dc67ad6cdc Mon Sep 17 00:00:00 2001 From: Pawel Franitza Date: Mon, 22 Sep 2025 10:14:43 +0200 Subject: [PATCH 1/2] feature(repo): Update build and source gen to >= 3.0.0 < 5.0.0 --- packages/theme_tailor/CHANGELOG.md | 4 ++++ packages/theme_tailor/pubspec.yaml | 6 +++--- packages/theme_tailor_annotation/CHANGELOG.md | 3 +++ packages/theme_tailor_annotation/pubspec.yaml | 2 +- packages/theme_tailor_toolbox/CHANGELOG.md | 3 +++ packages/theme_tailor_toolbox/pubspec.yaml | 2 +- 6 files changed, 15 insertions(+), 5 deletions(-) diff --git a/packages/theme_tailor/CHANGELOG.md b/packages/theme_tailor/CHANGELOG.md index eed9fc6..71a359d 100644 --- a/packages/theme_tailor/CHANGELOG.md +++ b/packages/theme_tailor/CHANGELOG.md @@ -1,3 +1,7 @@ +# 3.1.1 +- Support build 3.0.0 and ^4.0.0 +- Support source_gen 3.0.0 and ^4.0.0 + # 3.1.0 - Support build 3.0.0. - Support source_gen 3.0.0. diff --git a/packages/theme_tailor/pubspec.yaml b/packages/theme_tailor/pubspec.yaml index a12dd58..eb9a6c6 100644 --- a/packages/theme_tailor/pubspec.yaml +++ b/packages/theme_tailor/pubspec.yaml @@ -3,7 +3,7 @@ description: > Code generator for Flutter's 3.0 ThemeExtension classes. The generator can create themes and extensions on BuildContext or ThemeData based on the lists of the theme properties -version: 3.1.0 +version: 3.1.1 repository: https://github.com/Iteo/theme_tailor issue_tracker: https://github.com/Iteo/theme_tailor/issues homepage: https://github.com/Iteo/theme_tailor @@ -14,13 +14,13 @@ environment: dependencies: analyzer: ">=7.5.9 <8.0.0" - build: ^3.0.0 + build: ">=3.0.0 <5.0.0" build_config: ^1.1.0 collection: ^1.15.0 dart_style: ^3.0.1 json_annotation: ^4.6.0 meta: ^1.9.1 - source_gen: ^3.0.0 + source_gen: ">=3.0.0 <5.0.0" source_helper: ^1.3.2 theme_tailor_annotation: ^3.0.2 diff --git a/packages/theme_tailor_annotation/CHANGELOG.md b/packages/theme_tailor_annotation/CHANGELOG.md index a32d869..c1e7430 100644 --- a/packages/theme_tailor_annotation/CHANGELOG.md +++ b/packages/theme_tailor_annotation/CHANGELOG.md @@ -1,3 +1,6 @@ +# 3.1.1 +- Compatibility with theme_tailor 3.1.1 + # 3.1.0 - Support build 3.0.0. - Support source_gen 3.0.0. diff --git a/packages/theme_tailor_annotation/pubspec.yaml b/packages/theme_tailor_annotation/pubspec.yaml index f801ef1..899e752 100644 --- a/packages/theme_tailor_annotation/pubspec.yaml +++ b/packages/theme_tailor_annotation/pubspec.yaml @@ -2,7 +2,7 @@ name: theme_tailor_annotation description: > Annotations for the Theme Tailor code-generator. This package does nothing without Theme Tailor. -version: 3.1.0 +version: 3.1.1 repository: https://github.com/Iteo/theme_tailor issue_tracker: https://github.com/Iteo/theme_tailor/issues homepage: https://github.com/Iteo/theme_tailor diff --git a/packages/theme_tailor_toolbox/CHANGELOG.md b/packages/theme_tailor_toolbox/CHANGELOG.md index 3ae050d..f00d8fb 100644 --- a/packages/theme_tailor_toolbox/CHANGELOG.md +++ b/packages/theme_tailor_toolbox/CHANGELOG.md @@ -1,3 +1,6 @@ +# 3.1.1 +- Compatibility with theme_tailor 3.1.1 + # 3.1.0 - Require Dart 3.8.0 - Use the same versioning for other theme_tailor packages diff --git a/packages/theme_tailor_toolbox/pubspec.yaml b/packages/theme_tailor_toolbox/pubspec.yaml index bc1ef23..9f0f0c8 100644 --- a/packages/theme_tailor_toolbox/pubspec.yaml +++ b/packages/theme_tailor_toolbox/pubspec.yaml @@ -6,7 +6,7 @@ issue_tracker: https://github.com/Iteo/theme_tailor/issues homepage: https://github.com/Iteo/theme_tailor documentation: https://github.com/Iteo/theme_tailor/blob/main/packages/theme_tailor/README.md -version: 3.1.0 +version: 3.1.1 environment: sdk: ">=3.8.0 <4.0.0" From 0662041b8fb74125bfddaf0b9102da7c03a1534a Mon Sep 17 00:00:00 2001 From: Pawel Franitza Date: Mon, 22 Sep 2025 11:05:58 +0200 Subject: [PATCH 2/2] feature(repo): Support analyzer ^8.0.0 --- packages/theme_tailor/CHANGELOG.md | 2 ++ packages/theme_tailor/analysis_options.yaml | 3 +++ .../lib/src/model/referenced_packages.dart | 6 ++++++ .../extension/element_annotation_extension.dart | 16 +++++++++++----- .../src/util/extension/element_extension.dart | 11 +++++------ .../lib/src/util/theme_encoder_helper.dart | 8 +++----- packages/theme_tailor/pubspec.yaml | 4 ++-- packages/theme_tailor_annotation/CHANGELOG.md | 2 ++ ...xtension.dart => tailor_theme_extension.dart} | 6 +++--- .../lib/theme_tailor_annotation.dart | 2 +- packages/theme_tailor_toolbox/CHANGELOG.md | 1 + .../theme_tailor_toolbox/example/pubspec.lock | 14 +++++++------- 12 files changed, 46 insertions(+), 29 deletions(-) create mode 100644 packages/theme_tailor/lib/src/model/referenced_packages.dart rename packages/theme_tailor_annotation/lib/src/{theme_extension.dart => tailor_theme_extension.dart} (60%) diff --git a/packages/theme_tailor/CHANGELOG.md b/packages/theme_tailor/CHANGELOG.md index 71a359d..4fb5d88 100644 --- a/packages/theme_tailor/CHANGELOG.md +++ b/packages/theme_tailor/CHANGELOG.md @@ -1,6 +1,8 @@ # 3.1.1 +- Support analyzer: ">=7.5.9 <9.0.0" - Support build 3.0.0 and ^4.0.0 - Support source_gen 3.0.0 and ^4.0.0 +- Use the same versioning for other theme_tailor packages # 3.1.0 - Support build 3.0.0. diff --git a/packages/theme_tailor/analysis_options.yaml b/packages/theme_tailor/analysis_options.yaml index 0cc743e..f2fd596 100644 --- a/packages/theme_tailor/analysis_options.yaml +++ b/packages/theme_tailor/analysis_options.yaml @@ -4,3 +4,6 @@ analyzer: exclude: - "**/*.g.dart" - "**/*.tailor.dart" + errors: + # Remove when we require analyzer >=8 + deprecated_member_use: ignore diff --git a/packages/theme_tailor/lib/src/model/referenced_packages.dart b/packages/theme_tailor/lib/src/model/referenced_packages.dart new file mode 100644 index 0000000..0470264 --- /dev/null +++ b/packages/theme_tailor/lib/src/model/referenced_packages.dart @@ -0,0 +1,6 @@ +class ReferencedPackages { + const ReferencedPackages._(); + + static const themeTailorAnnotation = 'theme_tailor_annotation'; + static const jsonSerializable = 'json_serializable'; +} diff --git a/packages/theme_tailor/lib/src/util/extension/element_annotation_extension.dart b/packages/theme_tailor/lib/src/util/extension/element_annotation_extension.dart index 61a4b68..0f28ab2 100644 --- a/packages/theme_tailor/lib/src/util/extension/element_annotation_extension.dart +++ b/packages/theme_tailor/lib/src/util/extension/element_annotation_extension.dart @@ -1,14 +1,20 @@ -import 'package:analyzer/dart/element/element2.dart'; +import 'package:analyzer/dart/element/element.dart'; import 'package:source_gen/source_gen.dart'; +import 'package:theme_tailor/src/model/referenced_packages.dart'; import 'package:theme_tailor_annotation/theme_tailor_annotation.dart'; -extension ElementAnnotationExtension on ElementAnnotation { +extension ElementAnnotationExtension on Element2 { bool get isTailorAnnotation { - return const TypeChecker.fromRuntime(TailorMixin).isAssignableFromType(computeConstantValue()!.type!); + return const TypeChecker.typeNamed( + TailorMixin, + inPackage: ReferencedPackages.themeTailorAnnotation, + ).hasAnnotationOf(this, throwOnUnresolved: false); } bool get isTailorThemeExtension { - return TypeChecker.fromRuntime(themeExtension.runtimeType) - .isAssignableFrom(computeConstantValue()!.type!.element3!); + return const TypeChecker.typeNamed( + TailorThemeExtension, + inPackage: ReferencedPackages.themeTailorAnnotation, + ).isAssignableFrom(this); } } diff --git a/packages/theme_tailor/lib/src/util/extension/element_extension.dart b/packages/theme_tailor/lib/src/util/extension/element_extension.dart index d30c0c8..cbe635f 100644 --- a/packages/theme_tailor/lib/src/util/extension/element_extension.dart +++ b/packages/theme_tailor/lib/src/util/extension/element_extension.dart @@ -3,12 +3,13 @@ import 'package:collection/collection.dart'; import 'package:json_annotation/json_annotation.dart' show JsonSerializable; import 'package:source_gen/source_gen.dart'; import 'package:theme_tailor/src/model/constructor_data.dart'; +import 'package:theme_tailor/src/model/referenced_packages.dart'; import 'package:theme_tailor/src/util/extension/parameter_element_extension.dart'; import 'package:theme_tailor_annotation/theme_tailor_annotation.dart'; extension ElementExtension on Element2 { bool get hasJsonSerializableAnnotation { - const checker = TypeChecker.fromRuntime(JsonSerializable); + const checker = TypeChecker.typeNamed(JsonSerializable, inPackage: ReferencedPackages.jsonSerializable); return checker.hasAnnotationOf(this, throwOnUnresolved: false); } @@ -17,12 +18,12 @@ extension ElementExtension on Element2 { } bool get hasTailorMixinAnnotation { - const checker = TypeChecker.fromRuntime(TailorMixin); + const checker = TypeChecker.typeNamed(TailorMixin, inPackage: ReferencedPackages.jsonSerializable); return checker.hasAnnotationOf(this, throwOnUnresolved: false); } bool get hasThemeExtensionAnnotation { - final checker = TypeChecker.fromRuntime(themeExtension.runtimeType); + const checker = TypeChecker.typeNamed(TailorThemeExtension, inPackage: ReferencedPackages.themeTailorAnnotation); return checker.hasAnnotationOf(this, throwOnUnresolved: false); } } @@ -44,9 +45,7 @@ extension ClassElementExtensions on ClassElement2 { return ConstructorData( constructorName: ctor!.displayName, - parameterNameToType: Map.fromEntries( - parameters.map((e) => MapEntry(e.name3!, e.parameterType)), - ), + parameterNameToType: Map.fromEntries(parameters.map((e) => MapEntry(e.name3!, e.parameterType))), ); } } diff --git a/packages/theme_tailor/lib/src/util/theme_encoder_helper.dart b/packages/theme_tailor/lib/src/util/theme_encoder_helper.dart index 6e3dbef..53a42b6 100644 --- a/packages/theme_tailor/lib/src/util/theme_encoder_helper.dart +++ b/packages/theme_tailor/lib/src/util/theme_encoder_helper.dart @@ -3,10 +3,11 @@ import 'package:analyzer/dart/element/element2.dart'; import 'package:analyzer/dart/element/type.dart'; import 'package:collection/collection.dart'; import 'package:source_gen/source_gen.dart'; +import 'package:theme_tailor/src/model/referenced_packages.dart'; import 'package:theme_tailor/src/model/theme_encoder_data.dart'; import 'package:theme_tailor_annotation/theme_tailor_annotation.dart'; -const themeEncoderChecker = TypeChecker.fromRuntime(ThemeEncoder); +const themeEncoderChecker = TypeChecker.typeNamed(ThemeEncoder, inPackage: ReferencedPackages.themeTailorAnnotation); ThemeEncoderData? extractThemeEncoderData(ElementAnnotation? annotation, DartObject constantValue) { final encoderClassElement = constantValue.type!.element3 as ClassElement2?; @@ -33,10 +34,7 @@ ThemeEncoderData? extractThemeEncoderData(ElementAnnotation? annotation, DartObj accessString = '${enclosing.name3}.$accessString'; } - return ThemeEncoderData.propertyAccess( - accessString!, - encoderTypeStr, - ); + return ThemeEncoderData.propertyAccess(accessString!, encoderTypeStr); } final reviver = ConstantReader(constantValue).revive(); diff --git a/packages/theme_tailor/pubspec.yaml b/packages/theme_tailor/pubspec.yaml index eb9a6c6..5c24dd7 100644 --- a/packages/theme_tailor/pubspec.yaml +++ b/packages/theme_tailor/pubspec.yaml @@ -13,14 +13,14 @@ environment: sdk: ">=3.8.0 <4.0.0" dependencies: - analyzer: ">=7.5.9 <8.0.0" + analyzer: ">=7.5.9 <9.0.0" build: ">=3.0.0 <5.0.0" build_config: ^1.1.0 collection: ^1.15.0 dart_style: ^3.0.1 json_annotation: ^4.6.0 meta: ^1.9.1 - source_gen: ">=3.0.0 <5.0.0" + source_gen: ">=4.0.0 <5.0.0" source_helper: ^1.3.2 theme_tailor_annotation: ^3.0.2 diff --git a/packages/theme_tailor_annotation/CHANGELOG.md b/packages/theme_tailor_annotation/CHANGELOG.md index c1e7430..d9b1f0e 100644 --- a/packages/theme_tailor_annotation/CHANGELOG.md +++ b/packages/theme_tailor_annotation/CHANGELOG.md @@ -1,5 +1,7 @@ # 3.1.1 - Compatibility with theme_tailor 3.1.1 +- _ThemeExtension is now TailorThemeExtension, this class is annotation class and is exposed only for analyzer purposes. It is now possible to use @TailorThemeExtension instead @themeExtension, but using latter is recommended. +- Use the same versioning for other theme_tailor packages # 3.1.0 - Support build 3.0.0. diff --git a/packages/theme_tailor_annotation/lib/src/theme_extension.dart b/packages/theme_tailor_annotation/lib/src/tailor_theme_extension.dart similarity index 60% rename from packages/theme_tailor_annotation/lib/src/theme_extension.dart rename to packages/theme_tailor_annotation/lib/src/tailor_theme_extension.dart index 3e5283b..ebebcb3 100644 --- a/packages/theme_tailor_annotation/lib/src/theme_extension.dart +++ b/packages/theme_tailor_annotation/lib/src/tailor_theme_extension.dart @@ -2,9 +2,9 @@ import 'package:meta/meta_meta.dart'; /// Hints generator that the type conforms to ThemeExtension and can call lerp() /// on it. -const themeExtension = _ThemeExtension(); +const themeExtension = TailorThemeExtension(); @Target({TargetKind.field}) -class _ThemeExtension { - const _ThemeExtension(); +class TailorThemeExtension { + const TailorThemeExtension(); } diff --git a/packages/theme_tailor_annotation/lib/theme_tailor_annotation.dart b/packages/theme_tailor_annotation/lib/theme_tailor_annotation.dart index 87ee95e..fd34419 100644 --- a/packages/theme_tailor_annotation/lib/theme_tailor_annotation.dart +++ b/packages/theme_tailor_annotation/lib/theme_tailor_annotation.dart @@ -3,8 +3,8 @@ library theme_tailor_annotation; export 'package:collection/collection.dart' show DeepCollectionEquality; +export 'src/tailor_theme_extension.dart'; export 'src/theme_encoder.dart'; -export 'src/theme_extension.dart'; export 'src/theme_getter.dart'; export 'src/theme_ignore.dart'; export 'src/theme_tailor_mixin.dart'; diff --git a/packages/theme_tailor_toolbox/CHANGELOG.md b/packages/theme_tailor_toolbox/CHANGELOG.md index f00d8fb..45b0590 100644 --- a/packages/theme_tailor_toolbox/CHANGELOG.md +++ b/packages/theme_tailor_toolbox/CHANGELOG.md @@ -1,5 +1,6 @@ # 3.1.1 - Compatibility with theme_tailor 3.1.1 +- Use the same versioning for other theme_tailor packages # 3.1.0 - Require Dart 3.8.0 diff --git a/packages/theme_tailor_toolbox/example/pubspec.lock b/packages/theme_tailor_toolbox/example/pubspec.lock index 4133b30..9f9bfb6 100644 --- a/packages/theme_tailor_toolbox/example/pubspec.lock +++ b/packages/theme_tailor_toolbox/example/pubspec.lock @@ -420,18 +420,18 @@ packages: dependency: transitive description: name: source_gen - sha256: fc787b1f89ceac9580c3616f899c9a447413cbdac1df071302127764c023a134 + sha256: "800f12fb87434defa13432ab37e33051b43b290a174e15259563b043cda40c46" url: "https://pub.dev" source: hosted - version: "3.0.0" + version: "4.0.0" source_helper: dependency: transitive description: name: source_helper - sha256: "4f81479fe5194a622cdd1713fe1ecb683a6e6c85cd8cec8e2e35ee5ab3fdf2a1" + sha256: "6a3c6cc82073a8797f8c4dc4572146114a39652851c157db37e964d9c7038723" url: "https://pub.dev" source: hosted - version: "1.3.6" + version: "1.3.8" source_span: dependency: transitive description: @@ -494,21 +494,21 @@ packages: path: "../../theme_tailor" relative: true source: path - version: "3.1.0" + version: "3.1.1" theme_tailor_annotation: dependency: "direct main" description: path: "../../theme_tailor_annotation" relative: true source: path - version: "3.1.0" + version: "3.1.1" theme_tailor_toolbox: dependency: "direct main" description: path: ".." relative: true source: path - version: "3.1.0" + version: "3.1.1" timing: dependency: transitive description: