diff --git a/.github/workflows/dart.yml b/.github/workflows/dart.yml index e21b401a..20ac41c0 100644 --- a/.github/workflows/dart.yml +++ b/.github/workflows/dart.yml @@ -11,11 +11,11 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v2 + - uses: actions/checkout@v3 - uses: dart-lang/setup-dart@v1 with: sdk: stable - - name: init + - name: pub get run: .tools/init - name: format run: .tools/format @@ -41,7 +41,7 @@ jobs: - name: coverage run: .tools/coverage - name: upload coverage to codecov - uses: codecov/codecov-action@v1 + uses: codecov/codecov-action@v5 with: token: ${{ secrets.CODECOV_TOKEN }} files: coverage/lcov.info diff --git a/.tools/coverage b/.tools/coverage index 98a844b5..86871779 100755 --- a/.tools/coverage +++ b/.tools/coverage @@ -12,19 +12,19 @@ rm coverage/lcov.info 2>NUL echo NOTE sealed_annotations pushd sealed_annotations || exit 1 dart test --coverage dart_coverage || exit 1 -dart pub global run coverage:format_coverage -i dart_coverage -o coverage/lcov.info --lcov --packages .packages --report-on lib || exit 1 +dart pub global run coverage:format_coverage -i dart_coverage -o coverage/lcov.info --lcov --packages=.dart_tool/package_config.json --report-on lib || exit 1 popd || exit 1 echo NOTE sealed_writer pushd sealed_writer || exit 1 dart test --coverage dart_coverage || exit 1 -dart pub global run coverage:format_coverage -i dart_coverage -o coverage/lcov.info --lcov --packages .packages --report-on lib || exit 1 +dart pub global run coverage:format_coverage -i dart_coverage -o coverage/lcov.info --lcov --packages=.dart_tool/package_config.json --report-on lib || exit 1 popd || exit 1 echo NOTE sealed_generators pushd sealed_generators || exit 1 dart test --coverage dart_coverage || exit 1 -dart pub global run coverage:format_coverage -i dart_coverage -o coverage/lcov.info --lcov --packages .packages --report-on lib || exit 1 +dart pub global run coverage:format_coverage -i dart_coverage -o coverage/lcov.info --lcov --packages=.dart_tool/package_config.json --report-on lib || exit 1 popd || exit 1 echo NOTE combining coverage diff --git a/.tools/coverage.bat b/.tools/coverage.bat index 049361c2..f8acd07c 100755 --- a/.tools/coverage.bat +++ b/.tools/coverage.bat @@ -12,19 +12,19 @@ del coverage\lcov.info 2> NUL echo NOTE sealed_annotations pushd sealed_annotations || exit 1 call dart test --coverage dart_coverage || exit 1 -call dart pub global run coverage:format_coverage -i dart_coverage -o coverage/lcov.info --lcov --packages .packages --report-on lib || exit 1 +call dart pub global run coverage:format_coverage -i dart_coverage -o coverage/lcov.info --lcov --packages=.dart_tool/package_config.json --report-on lib || exit 1 popd || exit 1 echo NOTE sealed_writer pushd sealed_writer || exit 1 call dart test --coverage dart_coverage || exit 1 -call dart pub global run coverage:format_coverage -i dart_coverage -o coverage/lcov.info --lcov --packages .packages --report-on lib || exit 1 +call dart pub global run coverage:format_coverage -i dart_coverage -o coverage/lcov.info --lcov --packages=.dart_tool/package_config.json --report-on lib || exit 1 popd || exit 1 echo NOTE sealed_generators pushd sealed_generators || exit 1 call dart test --coverage dart_coverage || exit 1 -call dart pub global run coverage:format_coverage -i dart_coverage -o coverage/lcov.info --lcov --packages .packages --report-on lib || exit 1 +call dart pub global run coverage:format_coverage -i dart_coverage -o coverage/lcov.info --lcov --packages=.dart_tool/package_config.json --report-on lib || exit 1 popd || exit 1 echo NOTE combining coverage diff --git a/.tools/fix b/.tools/fix index d04498a3..2560e7e4 100755 --- a/.tools/fix +++ b/.tools/fix @@ -4,20 +4,20 @@ echo HEADER format pushd sealed_annotations || exit 1 echo NOTE sealed_annotations -dart format --fix lib test +dart format lib test popd || exit 1 pushd sealed_writer || exit 1 echo NOTE sealed_writer -dart format --fix lib test +dart format lib test popd || exit 1 pushd sealed_generators || exit 1 echo NOTE sealed_generators -dart format --fix lib test +dart format lib test popd || exit 1 pushd example || exit 1 echo NOTE example -dart format --fix test +dart format test popd || exit 1 diff --git a/.tools/fix.bat b/.tools/fix.bat index 496e6286..4201a5d9 100755 --- a/.tools/fix.bat +++ b/.tools/fix.bat @@ -4,20 +4,20 @@ echo HEADER format pushd sealed_annotations || exit 1 echo NOTE sealed_annotations -call dart format --fix lib test +call dart format lib test popd || exit 1 pushd sealed_writer || exit 1 echo NOTE sealed_writer -call dart format --fix lib test +call dart format lib test popd || exit 1 pushd sealed_generators || exit 1 echo NOTE sealed_generators -call dart format --fix lib test +call dart format lib test popd || exit 1 pushd example || exit 1 echo NOTE example -call dart format --fix test +call dart format test popd || exit 1 diff --git a/CHANGELOG.md b/CHANGELOG.md index d51605c6..1fba92ae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,11 @@ +## 2.0.0 + +- TODO + +## 1.14.0 + +- Fixed some issues + ## 1.13.0 - Added referToManifest to source writer diff --git a/LICENSE b/LICENSE index 2018725d..e7e4d00c 100644 --- a/LICENSE +++ b/LICENSE @@ -1,5 +1,6 @@ MIT License +Copyright (c) 2025 Amirreza Madani Copyright (c) 2021 6thsolution Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/README.md b/README.md index 1f3ca4ee..cff7af66 100644 --- a/README.md +++ b/README.md @@ -1,16 +1,19 @@ # Dart Sealed Class Generator -[![build](https://img.shields.io/github/workflow/status/6thsolution/dart_sealed/Dart?label=build)](https://github.com/6thsolution/dart_sealed/actions/workflows/dart.yml) -[![build](https://img.shields.io/codecov/c/gh/6thsolution/dart_sealed?label=coverage)](https://codecov.io/gh/6thsolution/dart_sealed) -[![pub](https://img.shields.io/pub/v/sealed_annotations.svg?color=blue&label=sealed_annotations)](https://pub.dev/packages/sealed_annotations) -[![pub](https://img.shields.io/pub/v/sealed_generators.svg?color=blue&label=sealed_generators)](https://pub.dev/packages/sealed_generators) -[![pub](https://img.shields.io/pub/v/sealed_writer.svg?color=blue&label=sealed_writer)](https://pub.dev/packages/sealed_writer) +[![build](https://img.shields.io/github/actions/workflow/status/FatulM/dart_sealed/.github/workflows/dart.yml?branch=master&label=build)](https://github.com/FatulM/dart_sealed/actions/workflows/dart.yml) +[![build](https://img.shields.io/codecov/c/gh/FatulM/dart_sealed?label=coverage)](https://codecov.io/gh/FatulM/dart_sealed) +[![pub](https://img.shields.io/badge/sealed__annotations-v2.0.0-blue)](https://github.com/FatulM/dart_sealed/tree/master/sealed_annotations) +[![pub](https://img.shields.io/badge/sealed__generators-v2.0.0-blue)](https://github.com/FatulM/dart_sealed/tree/master/sealed_generators) +[![version](https://img.shields.io/badge/sealed__writer-v2.0.0-blue)](https://github.com/FatulM/dart_sealed/tree/master/sealed_writer) Generate sealed class hierarchy for Dart and Flutter. +**NOTE** that this is only a clone of the upstream git repository +which I have fixed some issues and updated some dependencies. + ## Features -* Generate sealed class with abstract super type and data sub-classes. +* Generate sealed class with abstract super type and data subclasses. * Static factory methods. for example `Result.success(data: 0)`. * Cast methods. for example `a.asSuccess`, `a.isSuccess` or `a.asSuccessOrNull`. * Three types of equality and hashCode generation : data (like kotlin data classes), identity and distinct. @@ -26,12 +29,41 @@ Generate sealed class hierarchy for Dart and Flutter. Add dependencies in your `pubspec.yaml` file. +Since this is not the original repository, you can not use like this: + +```yaml +# WON'T WORK LIKE THIS: +dependencies: + sealed_annotations: '2.0.0' + +dev_dependencies: + sealed_generators: '2.0.0' +``` + +Instead, use like this: + +This will override the three dependencies to be downloaded from git. + ```yaml dependencies: - sealed_annotations: ^latest.version + sealed_annotations: '2.0.0' dev_dependencies: - sealed_generators: ^latest.version + sealed_generators: '2.0.0' + +dependency_overrides: + sealed_annotations: + git: + url: https://github.com/FatulM/dart_sealed + path: sealed_annotations/ + sealed_writer: + git: + url: https://github.com/FatulM/dart_sealed + path: sealed_writer/ + sealed_generators: + git: + url: https://github.com/FatulM/dart_sealed + path: sealed_generators/ ``` Import `sealed_annotations`. @@ -163,14 +195,14 @@ class WeatherWindy extends Weather { Notes: -- Prefer using factories in super class instead of sub-class constructors. like `Whether.rainy()` instead +- Prefer using factories in super class instead of subclass constructors. like `Whether.rainy()` instead of `WhetherRainy()` - Minimize usage of cast methods, most of the time they can be replaced with a match method. ## Equality and generated class names You can choose between three types of equality using `@WithEquality(...)` annotation. Default equality is `data` if not -specified. This will become default equality for all sub-classes. You can change equality of each sub-class by using +specified. This will become default equality for all subclasses. You can change equality of each subclass by using this annotation on individual methods. Equality types: @@ -209,14 +241,14 @@ abstract class _Weather { ``` An abstract super class is generated with name equal to name of manifest class without the underline (here `Weather`). -Each method will become a sub-class. There should be at least one method. sub-class names are based on method name +Each method will become a subclass. There should be at least one method. subclass names are based on method name prefixed with super class name (for example `WeatherSunny`). Naming process can be tailored with use of `@WithPrefix` -and `@WithName` annotations. Each method argument will become a field in corresponding sub-class. Field names are equal +and `@WithName` annotations. Each method argument will become a field in corresponding subclass. Field names are equal to argument names and field types are equal to argument types or dynamic if not specified. Argument types can be overridden using `@WithType` annotation for example when type information is not available at build time. Note that you can have nullable and non-nullable fields. -To change prefix of sub-class names which by default is top class name, you can use `@WithPrefix` annotation. for +To change prefix of subclass names which by default is top class name, you can use `@WithPrefix` annotation. for example: ```dart @@ -228,9 +260,9 @@ abstract class _Weather { ``` Now `sunny` will be named `HelloSunny` instead of the default `WeatherSunny`. You can use `@WithPrefix('')` to remove -all prefix from sub-class names. +all prefix from subclass names. -To change sub-class names directly you can use `@WithName` annotation. It will override `WithPrefix` if specified. for +To change subclass names directly you can use `@WithName` annotation. It will override `WithPrefix` if specified. for example: ```dart @@ -244,8 +276,8 @@ abstract class _Weather { Now `sunny` will be named `Hello` instead of the default `WeatherSunny`. This is useful if you want not to use prefix for some items. -Almost all methods on sealed classes use short names extracted from manifest method names. Full sub-class names are not -used. It is recommended not to use sub-classes directly. There are factory methods for each item on super class. +Almost all methods on sealed classes use short names extracted from manifest method names. Full subclass names are not +used. It is recommended not to use subclasses directly. There are factory methods for each item on super class. ## Generic Usage @@ -371,8 +403,8 @@ abstract class _Basket { Sometimes you need some fields to be present in all of your sealed classes. For example consider making a sealed class for different types of errors, and all of them are required to have `code` and `message`. It is very annoying to add -code and message to all of sealeds manually. Also if you have an error object you are unable to get its code or message -without using cast or match methods. Here you can use common fields. +code and message to all of sealed classes manually. Also, if you have an error object you are unable to get its code or +message without using cast or match methods. Here you can use common fields. To declare a common field you can add a getter or a final field to a manifest class, and it will automatically be added to all of your sealed classes. for example: @@ -397,9 +429,9 @@ abstract class _ApiError { You can also use a constructor in pair with final fields equivalently. -common fields are available on `ApiError` objects as well as it's sub-classes. +common fields are available on `ApiError` objects as well as its subclasses. -If you specify common fields in your seaeld classes it has no effect. for example: +If you specify common fields in your sealed classes it has no effect. for example: ```dart @Sealed() @@ -413,7 +445,7 @@ abstract class _Common { } ``` -You can use sub-class of common field type in sealed classes. For example: +You can use subclass of common field type in sealed classes. For example: ```dart @Sealed() diff --git a/example/CHANGELOG.md b/example/CHANGELOG.md index d51605c6..1fba92ae 100644 --- a/example/CHANGELOG.md +++ b/example/CHANGELOG.md @@ -1,3 +1,11 @@ +## 2.0.0 + +- TODO + +## 1.14.0 + +- Fixed some issues + ## 1.13.0 - Added referToManifest to source writer diff --git a/example/LICENSE b/example/LICENSE index 2018725d..e7e4d00c 100644 --- a/example/LICENSE +++ b/example/LICENSE @@ -1,5 +1,6 @@ MIT License +Copyright (c) 2025 Amirreza Madani Copyright (c) 2021 6thsolution Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/example/README.md b/example/README.md index 1f3ca4ee..cff7af66 100644 --- a/example/README.md +++ b/example/README.md @@ -1,16 +1,19 @@ # Dart Sealed Class Generator -[![build](https://img.shields.io/github/workflow/status/6thsolution/dart_sealed/Dart?label=build)](https://github.com/6thsolution/dart_sealed/actions/workflows/dart.yml) -[![build](https://img.shields.io/codecov/c/gh/6thsolution/dart_sealed?label=coverage)](https://codecov.io/gh/6thsolution/dart_sealed) -[![pub](https://img.shields.io/pub/v/sealed_annotations.svg?color=blue&label=sealed_annotations)](https://pub.dev/packages/sealed_annotations) -[![pub](https://img.shields.io/pub/v/sealed_generators.svg?color=blue&label=sealed_generators)](https://pub.dev/packages/sealed_generators) -[![pub](https://img.shields.io/pub/v/sealed_writer.svg?color=blue&label=sealed_writer)](https://pub.dev/packages/sealed_writer) +[![build](https://img.shields.io/github/actions/workflow/status/FatulM/dart_sealed/.github/workflows/dart.yml?branch=master&label=build)](https://github.com/FatulM/dart_sealed/actions/workflows/dart.yml) +[![build](https://img.shields.io/codecov/c/gh/FatulM/dart_sealed?label=coverage)](https://codecov.io/gh/FatulM/dart_sealed) +[![pub](https://img.shields.io/badge/sealed__annotations-v2.0.0-blue)](https://github.com/FatulM/dart_sealed/tree/master/sealed_annotations) +[![pub](https://img.shields.io/badge/sealed__generators-v2.0.0-blue)](https://github.com/FatulM/dart_sealed/tree/master/sealed_generators) +[![version](https://img.shields.io/badge/sealed__writer-v2.0.0-blue)](https://github.com/FatulM/dart_sealed/tree/master/sealed_writer) Generate sealed class hierarchy for Dart and Flutter. +**NOTE** that this is only a clone of the upstream git repository +which I have fixed some issues and updated some dependencies. + ## Features -* Generate sealed class with abstract super type and data sub-classes. +* Generate sealed class with abstract super type and data subclasses. * Static factory methods. for example `Result.success(data: 0)`. * Cast methods. for example `a.asSuccess`, `a.isSuccess` or `a.asSuccessOrNull`. * Three types of equality and hashCode generation : data (like kotlin data classes), identity and distinct. @@ -26,12 +29,41 @@ Generate sealed class hierarchy for Dart and Flutter. Add dependencies in your `pubspec.yaml` file. +Since this is not the original repository, you can not use like this: + +```yaml +# WON'T WORK LIKE THIS: +dependencies: + sealed_annotations: '2.0.0' + +dev_dependencies: + sealed_generators: '2.0.0' +``` + +Instead, use like this: + +This will override the three dependencies to be downloaded from git. + ```yaml dependencies: - sealed_annotations: ^latest.version + sealed_annotations: '2.0.0' dev_dependencies: - sealed_generators: ^latest.version + sealed_generators: '2.0.0' + +dependency_overrides: + sealed_annotations: + git: + url: https://github.com/FatulM/dart_sealed + path: sealed_annotations/ + sealed_writer: + git: + url: https://github.com/FatulM/dart_sealed + path: sealed_writer/ + sealed_generators: + git: + url: https://github.com/FatulM/dart_sealed + path: sealed_generators/ ``` Import `sealed_annotations`. @@ -163,14 +195,14 @@ class WeatherWindy extends Weather { Notes: -- Prefer using factories in super class instead of sub-class constructors. like `Whether.rainy()` instead +- Prefer using factories in super class instead of subclass constructors. like `Whether.rainy()` instead of `WhetherRainy()` - Minimize usage of cast methods, most of the time they can be replaced with a match method. ## Equality and generated class names You can choose between three types of equality using `@WithEquality(...)` annotation. Default equality is `data` if not -specified. This will become default equality for all sub-classes. You can change equality of each sub-class by using +specified. This will become default equality for all subclasses. You can change equality of each subclass by using this annotation on individual methods. Equality types: @@ -209,14 +241,14 @@ abstract class _Weather { ``` An abstract super class is generated with name equal to name of manifest class without the underline (here `Weather`). -Each method will become a sub-class. There should be at least one method. sub-class names are based on method name +Each method will become a subclass. There should be at least one method. subclass names are based on method name prefixed with super class name (for example `WeatherSunny`). Naming process can be tailored with use of `@WithPrefix` -and `@WithName` annotations. Each method argument will become a field in corresponding sub-class. Field names are equal +and `@WithName` annotations. Each method argument will become a field in corresponding subclass. Field names are equal to argument names and field types are equal to argument types or dynamic if not specified. Argument types can be overridden using `@WithType` annotation for example when type information is not available at build time. Note that you can have nullable and non-nullable fields. -To change prefix of sub-class names which by default is top class name, you can use `@WithPrefix` annotation. for +To change prefix of subclass names which by default is top class name, you can use `@WithPrefix` annotation. for example: ```dart @@ -228,9 +260,9 @@ abstract class _Weather { ``` Now `sunny` will be named `HelloSunny` instead of the default `WeatherSunny`. You can use `@WithPrefix('')` to remove -all prefix from sub-class names. +all prefix from subclass names. -To change sub-class names directly you can use `@WithName` annotation. It will override `WithPrefix` if specified. for +To change subclass names directly you can use `@WithName` annotation. It will override `WithPrefix` if specified. for example: ```dart @@ -244,8 +276,8 @@ abstract class _Weather { Now `sunny` will be named `Hello` instead of the default `WeatherSunny`. This is useful if you want not to use prefix for some items. -Almost all methods on sealed classes use short names extracted from manifest method names. Full sub-class names are not -used. It is recommended not to use sub-classes directly. There are factory methods for each item on super class. +Almost all methods on sealed classes use short names extracted from manifest method names. Full subclass names are not +used. It is recommended not to use subclasses directly. There are factory methods for each item on super class. ## Generic Usage @@ -371,8 +403,8 @@ abstract class _Basket { Sometimes you need some fields to be present in all of your sealed classes. For example consider making a sealed class for different types of errors, and all of them are required to have `code` and `message`. It is very annoying to add -code and message to all of sealeds manually. Also if you have an error object you are unable to get its code or message -without using cast or match methods. Here you can use common fields. +code and message to all of sealed classes manually. Also, if you have an error object you are unable to get its code or +message without using cast or match methods. Here you can use common fields. To declare a common field you can add a getter or a final field to a manifest class, and it will automatically be added to all of your sealed classes. for example: @@ -397,9 +429,9 @@ abstract class _ApiError { You can also use a constructor in pair with final fields equivalently. -common fields are available on `ApiError` objects as well as it's sub-classes. +common fields are available on `ApiError` objects as well as its subclasses. -If you specify common fields in your seaeld classes it has no effect. for example: +If you specify common fields in your sealed classes it has no effect. for example: ```dart @Sealed() @@ -413,7 +445,7 @@ abstract class _Common { } ``` -You can use sub-class of common field type in sealed classes. For example: +You can use subclass of common field type in sealed classes. For example: ```dart @Sealed() diff --git a/example/analysis_options.yaml b/example/analysis_options.yaml index 7d7c0831..939066c4 100644 --- a/example/analysis_options.yaml +++ b/example/analysis_options.yaml @@ -1,6 +1,8 @@ include: package:lints/recommended.yaml analyzer: - strong-mode: - implicit-dynamic: false - implicit-casts: false + language: + strict-casts: true + strict-inference: true + strict-raw-types: true + diff --git a/example/bin/sealed/nullsafe/data/generic/result.sealed.dart b/example/bin/sealed/nullsafe/data/generic/result.sealed.dart index ac95b722..9efb653c 100644 --- a/example/bin/sealed/nullsafe/data/generic/result.sealed.dart +++ b/example/bin/sealed/nullsafe/data/generic/result.sealed.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'result.dart'; diff --git a/example/bin/sealed/nullsafe/data/generic/result_common.sealed.dart b/example/bin/sealed/nullsafe/data/generic/result_common.sealed.dart index aed445b6..9a941e1c 100644 --- a/example/bin/sealed/nullsafe/data/generic/result_common.sealed.dart +++ b/example/bin/sealed/nullsafe/data/generic/result_common.sealed.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'result_common.dart'; diff --git a/example/bin/sealed/nullsafe/data/generic/result_common_split.sealed.dart b/example/bin/sealed/nullsafe/data/generic/result_common_split.sealed.dart index 4ce45689..d4c6f20e 100644 --- a/example/bin/sealed/nullsafe/data/generic/result_common_split.sealed.dart +++ b/example/bin/sealed/nullsafe/data/generic/result_common_split.sealed.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'result_common_split.dart'; diff --git a/example/bin/sealed/nullsafe/data/generic/result_complex.sealed.dart b/example/bin/sealed/nullsafe/data/generic/result_complex.sealed.dart index ba2cbf4a..68425e32 100644 --- a/example/bin/sealed/nullsafe/data/generic/result_complex.sealed.dart +++ b/example/bin/sealed/nullsafe/data/generic/result_complex.sealed.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'result_complex.dart'; diff --git a/example/bin/sealed/nullsafe/data/generic/result_hierarchy.sealed.dart b/example/bin/sealed/nullsafe/data/generic/result_hierarchy.sealed.dart index f2c52cc7..9fcf44c2 100644 --- a/example/bin/sealed/nullsafe/data/generic/result_hierarchy.sealed.dart +++ b/example/bin/sealed/nullsafe/data/generic/result_hierarchy.sealed.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'result_hierarchy.dart'; diff --git a/example/bin/sealed/nullsafe/data/generic/result_multi_1.sealed.dart b/example/bin/sealed/nullsafe/data/generic/result_multi_1.sealed.dart index 68ed307a..45f52d68 100644 --- a/example/bin/sealed/nullsafe/data/generic/result_multi_1.sealed.dart +++ b/example/bin/sealed/nullsafe/data/generic/result_multi_1.sealed.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'result_multi_1.dart'; diff --git a/example/bin/sealed/nullsafe/data/generic/result_multi_2.sealed.dart b/example/bin/sealed/nullsafe/data/generic/result_multi_2.sealed.dart index 015ece01..389d10ec 100644 --- a/example/bin/sealed/nullsafe/data/generic/result_multi_2.sealed.dart +++ b/example/bin/sealed/nullsafe/data/generic/result_multi_2.sealed.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'result_multi_2.dart'; diff --git a/example/bin/sealed/nullsafe/data/generic/result_multi_3.sealed.dart b/example/bin/sealed/nullsafe/data/generic/result_multi_3.sealed.dart index a8e744ba..e281869f 100644 --- a/example/bin/sealed/nullsafe/data/generic/result_multi_3.sealed.dart +++ b/example/bin/sealed/nullsafe/data/generic/result_multi_3.sealed.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'result_multi_3.dart'; diff --git a/example/bin/sealed/nullsafe/data/generic/result_multi_4.sealed.dart b/example/bin/sealed/nullsafe/data/generic/result_multi_4.sealed.dart index 455e642f..8f8af44d 100644 --- a/example/bin/sealed/nullsafe/data/generic/result_multi_4.sealed.dart +++ b/example/bin/sealed/nullsafe/data/generic/result_multi_4.sealed.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'result_multi_4.dart'; diff --git a/example/bin/sealed/nullsafe/data/generic/result_no_upper_1.sealed.dart b/example/bin/sealed/nullsafe/data/generic/result_no_upper_1.sealed.dart index e86916f0..c2e04bdf 100644 --- a/example/bin/sealed/nullsafe/data/generic/result_no_upper_1.sealed.dart +++ b/example/bin/sealed/nullsafe/data/generic/result_no_upper_1.sealed.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'result_no_upper_1.dart'; diff --git a/example/bin/sealed/nullsafe/data/generic/result_no_upper_2.sealed.dart b/example/bin/sealed/nullsafe/data/generic/result_no_upper_2.sealed.dart index 79094425..0e82230d 100644 --- a/example/bin/sealed/nullsafe/data/generic/result_no_upper_2.sealed.dart +++ b/example/bin/sealed/nullsafe/data/generic/result_no_upper_2.sealed.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'result_no_upper_2.dart'; diff --git a/example/bin/sealed/nullsafe/data/generic/result_single_1.sealed.dart b/example/bin/sealed/nullsafe/data/generic/result_single_1.sealed.dart index 29a497b3..4b613299 100644 --- a/example/bin/sealed/nullsafe/data/generic/result_single_1.sealed.dart +++ b/example/bin/sealed/nullsafe/data/generic/result_single_1.sealed.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'result_single_1.dart'; diff --git a/example/bin/sealed/nullsafe/data/generic/result_single_2.sealed.dart b/example/bin/sealed/nullsafe/data/generic/result_single_2.sealed.dart index f2b93f18..59ee429a 100644 --- a/example/bin/sealed/nullsafe/data/generic/result_single_2.sealed.dart +++ b/example/bin/sealed/nullsafe/data/generic/result_single_2.sealed.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'result_single_2.dart'; diff --git a/example/bin/sealed/nullsafe/data/generic/result_single_3.sealed.dart b/example/bin/sealed/nullsafe/data/generic/result_single_3.sealed.dart index 090e26b1..0f414048 100644 --- a/example/bin/sealed/nullsafe/data/generic/result_single_3.sealed.dart +++ b/example/bin/sealed/nullsafe/data/generic/result_single_3.sealed.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'result_single_3.dart'; diff --git a/example/bin/sealed/nullsafe/data/generic/result_single_4.sealed.dart b/example/bin/sealed/nullsafe/data/generic/result_single_4.sealed.dart index 48448ec1..c5ef3156 100644 --- a/example/bin/sealed/nullsafe/data/generic/result_single_4.sealed.dart +++ b/example/bin/sealed/nullsafe/data/generic/result_single_4.sealed.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'result_single_4.dart'; diff --git a/example/bin/sealed/nullsafe/data/simple/common.sealed.dart b/example/bin/sealed/nullsafe/data/simple/common.sealed.dart index 9a1d9a12..ca480c99 100644 --- a/example/bin/sealed/nullsafe/data/simple/common.sealed.dart +++ b/example/bin/sealed/nullsafe/data/simple/common.sealed.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'common.dart'; diff --git a/example/bin/sealed/nullsafe/data/simple/common_complex.sealed.dart b/example/bin/sealed/nullsafe/data/simple/common_complex.sealed.dart index ad3f9f11..cfc7a425 100644 --- a/example/bin/sealed/nullsafe/data/simple/common_complex.sealed.dart +++ b/example/bin/sealed/nullsafe/data/simple/common_complex.sealed.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'common_complex.dart'; diff --git a/example/bin/sealed/nullsafe/data/simple/functional.sealed.dart b/example/bin/sealed/nullsafe/data/simple/functional.sealed.dart index 7f9bbd4c..07800d07 100644 --- a/example/bin/sealed/nullsafe/data/simple/functional.sealed.dart +++ b/example/bin/sealed/nullsafe/data/simple/functional.sealed.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'functional.dart'; diff --git a/example/bin/sealed/nullsafe/data/simple/hierarchy.sealed.dart b/example/bin/sealed/nullsafe/data/simple/hierarchy.sealed.dart index fd2a2379..b261e5ec 100644 --- a/example/bin/sealed/nullsafe/data/simple/hierarchy.sealed.dart +++ b/example/bin/sealed/nullsafe/data/simple/hierarchy.sealed.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'hierarchy.dart'; diff --git a/example/bin/sealed/nullsafe/data/simple/meta.sealed.dart b/example/bin/sealed/nullsafe/data/simple/meta.sealed.dart index c9206305..61f8176b 100644 --- a/example/bin/sealed/nullsafe/data/simple/meta.sealed.dart +++ b/example/bin/sealed/nullsafe/data/simple/meta.sealed.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'meta.dart'; diff --git a/example/bin/sealed/nullsafe/data/simple/mixed.sealed.dart b/example/bin/sealed/nullsafe/data/simple/mixed.sealed.dart index 714eed71..1a0e5359 100644 --- a/example/bin/sealed/nullsafe/data/simple/mixed.sealed.dart +++ b/example/bin/sealed/nullsafe/data/simple/mixed.sealed.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'mixed.dart'; diff --git a/example/bin/sealed/nullsafe/data/simple/weather.sealed.dart b/example/bin/sealed/nullsafe/data/simple/weather.sealed.dart index 313adf10..c4259ed6 100644 --- a/example/bin/sealed/nullsafe/data/simple/weather.sealed.dart +++ b/example/bin/sealed/nullsafe/data/simple/weather.sealed.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'weather.dart'; diff --git a/example/bin/sealed/nullsafe/distinct/simple/weather.sealed.dart b/example/bin/sealed/nullsafe/distinct/simple/weather.sealed.dart index 4fc7f1ca..30465f14 100644 --- a/example/bin/sealed/nullsafe/distinct/simple/weather.sealed.dart +++ b/example/bin/sealed/nullsafe/distinct/simple/weather.sealed.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'weather.dart'; diff --git a/example/bin/sealed/nullsafe/identity/simple/weather.sealed.dart b/example/bin/sealed/nullsafe/identity/simple/weather.sealed.dart index 1c4f9fc0..6cc63dcf 100644 --- a/example/bin/sealed/nullsafe/identity/simple/weather.sealed.dart +++ b/example/bin/sealed/nullsafe/identity/simple/weather.sealed.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'weather.dart'; diff --git a/example/pubspec.yaml b/example/pubspec.yaml index cce4031e..2ae1d3d4 100644 --- a/example/pubspec.yaml +++ b/example/pubspec.yaml @@ -1,28 +1,26 @@ name: example description: Dart and Flutter sealed or union class generator and annotations, with match methods and other utilities. -repository: https://github.com/6thsolution/dart_sealed/tree/master/example -homepage: https://github.com/6thsolution/dart_sealed +repository: https://github.com/FatulM/dart_sealed/tree/master/example +homepage: https://github.com/FatulM/dart_sealed -version: 1.13.0 +version: 2.0.0 # example package should not be published publish_to: 'none' environment: - sdk: '>=2.12.0 <3.0.0' + sdk: '>=2.12.0 <4.0.0' dependencies: - # use fixed version dependency - sealed_annotations: '1.13.0' + sealed_annotations: '2.0.0' dev_dependencies: - # use fixed version dependency - sealed_generators: '1.13.0' + sealed_generators: '2.0.0' lints: any test: any build_runner: any -# remove this on pub branch +# Remove this on your own projects: dependency_overrides: sealed_annotations: path: ../sealed_annotations @@ -30,3 +28,18 @@ dependency_overrides: path: ../sealed_writer sealed_generators: path: ../sealed_generators + +# Use this on your own projects instead: +#dependency_overrides: +# sealed_annotations: +# git: +# url: https://github.com/FatulM/dart_sealed +# path: sealed_annotations/ +# sealed_writer: +# git: +# url: https://github.com/FatulM/dart_sealed +# path: sealed_writer/ +# sealed_generators: +# git: +# url: https://github.com/FatulM/dart_sealed +# path: sealed_generators/ diff --git a/sealed_annotations/CHANGELOG.md b/sealed_annotations/CHANGELOG.md index d51605c6..1fba92ae 100644 --- a/sealed_annotations/CHANGELOG.md +++ b/sealed_annotations/CHANGELOG.md @@ -1,3 +1,11 @@ +## 2.0.0 + +- TODO + +## 1.14.0 + +- Fixed some issues + ## 1.13.0 - Added referToManifest to source writer diff --git a/sealed_annotations/LICENSE b/sealed_annotations/LICENSE index 2018725d..e7e4d00c 100644 --- a/sealed_annotations/LICENSE +++ b/sealed_annotations/LICENSE @@ -1,5 +1,6 @@ MIT License +Copyright (c) 2025 Amirreza Madani Copyright (c) 2021 6thsolution Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/sealed_annotations/README.md b/sealed_annotations/README.md index 1f3ca4ee..cff7af66 100644 --- a/sealed_annotations/README.md +++ b/sealed_annotations/README.md @@ -1,16 +1,19 @@ # Dart Sealed Class Generator -[![build](https://img.shields.io/github/workflow/status/6thsolution/dart_sealed/Dart?label=build)](https://github.com/6thsolution/dart_sealed/actions/workflows/dart.yml) -[![build](https://img.shields.io/codecov/c/gh/6thsolution/dart_sealed?label=coverage)](https://codecov.io/gh/6thsolution/dart_sealed) -[![pub](https://img.shields.io/pub/v/sealed_annotations.svg?color=blue&label=sealed_annotations)](https://pub.dev/packages/sealed_annotations) -[![pub](https://img.shields.io/pub/v/sealed_generators.svg?color=blue&label=sealed_generators)](https://pub.dev/packages/sealed_generators) -[![pub](https://img.shields.io/pub/v/sealed_writer.svg?color=blue&label=sealed_writer)](https://pub.dev/packages/sealed_writer) +[![build](https://img.shields.io/github/actions/workflow/status/FatulM/dart_sealed/.github/workflows/dart.yml?branch=master&label=build)](https://github.com/FatulM/dart_sealed/actions/workflows/dart.yml) +[![build](https://img.shields.io/codecov/c/gh/FatulM/dart_sealed?label=coverage)](https://codecov.io/gh/FatulM/dart_sealed) +[![pub](https://img.shields.io/badge/sealed__annotations-v2.0.0-blue)](https://github.com/FatulM/dart_sealed/tree/master/sealed_annotations) +[![pub](https://img.shields.io/badge/sealed__generators-v2.0.0-blue)](https://github.com/FatulM/dart_sealed/tree/master/sealed_generators) +[![version](https://img.shields.io/badge/sealed__writer-v2.0.0-blue)](https://github.com/FatulM/dart_sealed/tree/master/sealed_writer) Generate sealed class hierarchy for Dart and Flutter. +**NOTE** that this is only a clone of the upstream git repository +which I have fixed some issues and updated some dependencies. + ## Features -* Generate sealed class with abstract super type and data sub-classes. +* Generate sealed class with abstract super type and data subclasses. * Static factory methods. for example `Result.success(data: 0)`. * Cast methods. for example `a.asSuccess`, `a.isSuccess` or `a.asSuccessOrNull`. * Three types of equality and hashCode generation : data (like kotlin data classes), identity and distinct. @@ -26,12 +29,41 @@ Generate sealed class hierarchy for Dart and Flutter. Add dependencies in your `pubspec.yaml` file. +Since this is not the original repository, you can not use like this: + +```yaml +# WON'T WORK LIKE THIS: +dependencies: + sealed_annotations: '2.0.0' + +dev_dependencies: + sealed_generators: '2.0.0' +``` + +Instead, use like this: + +This will override the three dependencies to be downloaded from git. + ```yaml dependencies: - sealed_annotations: ^latest.version + sealed_annotations: '2.0.0' dev_dependencies: - sealed_generators: ^latest.version + sealed_generators: '2.0.0' + +dependency_overrides: + sealed_annotations: + git: + url: https://github.com/FatulM/dart_sealed + path: sealed_annotations/ + sealed_writer: + git: + url: https://github.com/FatulM/dart_sealed + path: sealed_writer/ + sealed_generators: + git: + url: https://github.com/FatulM/dart_sealed + path: sealed_generators/ ``` Import `sealed_annotations`. @@ -163,14 +195,14 @@ class WeatherWindy extends Weather { Notes: -- Prefer using factories in super class instead of sub-class constructors. like `Whether.rainy()` instead +- Prefer using factories in super class instead of subclass constructors. like `Whether.rainy()` instead of `WhetherRainy()` - Minimize usage of cast methods, most of the time they can be replaced with a match method. ## Equality and generated class names You can choose between three types of equality using `@WithEquality(...)` annotation. Default equality is `data` if not -specified. This will become default equality for all sub-classes. You can change equality of each sub-class by using +specified. This will become default equality for all subclasses. You can change equality of each subclass by using this annotation on individual methods. Equality types: @@ -209,14 +241,14 @@ abstract class _Weather { ``` An abstract super class is generated with name equal to name of manifest class without the underline (here `Weather`). -Each method will become a sub-class. There should be at least one method. sub-class names are based on method name +Each method will become a subclass. There should be at least one method. subclass names are based on method name prefixed with super class name (for example `WeatherSunny`). Naming process can be tailored with use of `@WithPrefix` -and `@WithName` annotations. Each method argument will become a field in corresponding sub-class. Field names are equal +and `@WithName` annotations. Each method argument will become a field in corresponding subclass. Field names are equal to argument names and field types are equal to argument types or dynamic if not specified. Argument types can be overridden using `@WithType` annotation for example when type information is not available at build time. Note that you can have nullable and non-nullable fields. -To change prefix of sub-class names which by default is top class name, you can use `@WithPrefix` annotation. for +To change prefix of subclass names which by default is top class name, you can use `@WithPrefix` annotation. for example: ```dart @@ -228,9 +260,9 @@ abstract class _Weather { ``` Now `sunny` will be named `HelloSunny` instead of the default `WeatherSunny`. You can use `@WithPrefix('')` to remove -all prefix from sub-class names. +all prefix from subclass names. -To change sub-class names directly you can use `@WithName` annotation. It will override `WithPrefix` if specified. for +To change subclass names directly you can use `@WithName` annotation. It will override `WithPrefix` if specified. for example: ```dart @@ -244,8 +276,8 @@ abstract class _Weather { Now `sunny` will be named `Hello` instead of the default `WeatherSunny`. This is useful if you want not to use prefix for some items. -Almost all methods on sealed classes use short names extracted from manifest method names. Full sub-class names are not -used. It is recommended not to use sub-classes directly. There are factory methods for each item on super class. +Almost all methods on sealed classes use short names extracted from manifest method names. Full subclass names are not +used. It is recommended not to use subclasses directly. There are factory methods for each item on super class. ## Generic Usage @@ -371,8 +403,8 @@ abstract class _Basket { Sometimes you need some fields to be present in all of your sealed classes. For example consider making a sealed class for different types of errors, and all of them are required to have `code` and `message`. It is very annoying to add -code and message to all of sealeds manually. Also if you have an error object you are unable to get its code or message -without using cast or match methods. Here you can use common fields. +code and message to all of sealed classes manually. Also, if you have an error object you are unable to get its code or +message without using cast or match methods. Here you can use common fields. To declare a common field you can add a getter or a final field to a manifest class, and it will automatically be added to all of your sealed classes. for example: @@ -397,9 +429,9 @@ abstract class _ApiError { You can also use a constructor in pair with final fields equivalently. -common fields are available on `ApiError` objects as well as it's sub-classes. +common fields are available on `ApiError` objects as well as its subclasses. -If you specify common fields in your seaeld classes it has no effect. for example: +If you specify common fields in your sealed classes it has no effect. for example: ```dart @Sealed() @@ -413,7 +445,7 @@ abstract class _Common { } ``` -You can use sub-class of common field type in sealed classes. For example: +You can use subclass of common field type in sealed classes. For example: ```dart @Sealed() diff --git a/sealed_annotations/analysis_options.yaml b/sealed_annotations/analysis_options.yaml index 7d7c0831..939066c4 100644 --- a/sealed_annotations/analysis_options.yaml +++ b/sealed_annotations/analysis_options.yaml @@ -1,6 +1,8 @@ include: package:lints/recommended.yaml analyzer: - strong-mode: - implicit-dynamic: false - implicit-casts: false + language: + strict-casts: true + strict-inference: true + strict-raw-types: true + diff --git a/sealed_annotations/example/README.md b/sealed_annotations/example/README.md index 1f3ca4ee..cff7af66 100644 --- a/sealed_annotations/example/README.md +++ b/sealed_annotations/example/README.md @@ -1,16 +1,19 @@ # Dart Sealed Class Generator -[![build](https://img.shields.io/github/workflow/status/6thsolution/dart_sealed/Dart?label=build)](https://github.com/6thsolution/dart_sealed/actions/workflows/dart.yml) -[![build](https://img.shields.io/codecov/c/gh/6thsolution/dart_sealed?label=coverage)](https://codecov.io/gh/6thsolution/dart_sealed) -[![pub](https://img.shields.io/pub/v/sealed_annotations.svg?color=blue&label=sealed_annotations)](https://pub.dev/packages/sealed_annotations) -[![pub](https://img.shields.io/pub/v/sealed_generators.svg?color=blue&label=sealed_generators)](https://pub.dev/packages/sealed_generators) -[![pub](https://img.shields.io/pub/v/sealed_writer.svg?color=blue&label=sealed_writer)](https://pub.dev/packages/sealed_writer) +[![build](https://img.shields.io/github/actions/workflow/status/FatulM/dart_sealed/.github/workflows/dart.yml?branch=master&label=build)](https://github.com/FatulM/dart_sealed/actions/workflows/dart.yml) +[![build](https://img.shields.io/codecov/c/gh/FatulM/dart_sealed?label=coverage)](https://codecov.io/gh/FatulM/dart_sealed) +[![pub](https://img.shields.io/badge/sealed__annotations-v2.0.0-blue)](https://github.com/FatulM/dart_sealed/tree/master/sealed_annotations) +[![pub](https://img.shields.io/badge/sealed__generators-v2.0.0-blue)](https://github.com/FatulM/dart_sealed/tree/master/sealed_generators) +[![version](https://img.shields.io/badge/sealed__writer-v2.0.0-blue)](https://github.com/FatulM/dart_sealed/tree/master/sealed_writer) Generate sealed class hierarchy for Dart and Flutter. +**NOTE** that this is only a clone of the upstream git repository +which I have fixed some issues and updated some dependencies. + ## Features -* Generate sealed class with abstract super type and data sub-classes. +* Generate sealed class with abstract super type and data subclasses. * Static factory methods. for example `Result.success(data: 0)`. * Cast methods. for example `a.asSuccess`, `a.isSuccess` or `a.asSuccessOrNull`. * Three types of equality and hashCode generation : data (like kotlin data classes), identity and distinct. @@ -26,12 +29,41 @@ Generate sealed class hierarchy for Dart and Flutter. Add dependencies in your `pubspec.yaml` file. +Since this is not the original repository, you can not use like this: + +```yaml +# WON'T WORK LIKE THIS: +dependencies: + sealed_annotations: '2.0.0' + +dev_dependencies: + sealed_generators: '2.0.0' +``` + +Instead, use like this: + +This will override the three dependencies to be downloaded from git. + ```yaml dependencies: - sealed_annotations: ^latest.version + sealed_annotations: '2.0.0' dev_dependencies: - sealed_generators: ^latest.version + sealed_generators: '2.0.0' + +dependency_overrides: + sealed_annotations: + git: + url: https://github.com/FatulM/dart_sealed + path: sealed_annotations/ + sealed_writer: + git: + url: https://github.com/FatulM/dart_sealed + path: sealed_writer/ + sealed_generators: + git: + url: https://github.com/FatulM/dart_sealed + path: sealed_generators/ ``` Import `sealed_annotations`. @@ -163,14 +195,14 @@ class WeatherWindy extends Weather { Notes: -- Prefer using factories in super class instead of sub-class constructors. like `Whether.rainy()` instead +- Prefer using factories in super class instead of subclass constructors. like `Whether.rainy()` instead of `WhetherRainy()` - Minimize usage of cast methods, most of the time they can be replaced with a match method. ## Equality and generated class names You can choose between three types of equality using `@WithEquality(...)` annotation. Default equality is `data` if not -specified. This will become default equality for all sub-classes. You can change equality of each sub-class by using +specified. This will become default equality for all subclasses. You can change equality of each subclass by using this annotation on individual methods. Equality types: @@ -209,14 +241,14 @@ abstract class _Weather { ``` An abstract super class is generated with name equal to name of manifest class without the underline (here `Weather`). -Each method will become a sub-class. There should be at least one method. sub-class names are based on method name +Each method will become a subclass. There should be at least one method. subclass names are based on method name prefixed with super class name (for example `WeatherSunny`). Naming process can be tailored with use of `@WithPrefix` -and `@WithName` annotations. Each method argument will become a field in corresponding sub-class. Field names are equal +and `@WithName` annotations. Each method argument will become a field in corresponding subclass. Field names are equal to argument names and field types are equal to argument types or dynamic if not specified. Argument types can be overridden using `@WithType` annotation for example when type information is not available at build time. Note that you can have nullable and non-nullable fields. -To change prefix of sub-class names which by default is top class name, you can use `@WithPrefix` annotation. for +To change prefix of subclass names which by default is top class name, you can use `@WithPrefix` annotation. for example: ```dart @@ -228,9 +260,9 @@ abstract class _Weather { ``` Now `sunny` will be named `HelloSunny` instead of the default `WeatherSunny`. You can use `@WithPrefix('')` to remove -all prefix from sub-class names. +all prefix from subclass names. -To change sub-class names directly you can use `@WithName` annotation. It will override `WithPrefix` if specified. for +To change subclass names directly you can use `@WithName` annotation. It will override `WithPrefix` if specified. for example: ```dart @@ -244,8 +276,8 @@ abstract class _Weather { Now `sunny` will be named `Hello` instead of the default `WeatherSunny`. This is useful if you want not to use prefix for some items. -Almost all methods on sealed classes use short names extracted from manifest method names. Full sub-class names are not -used. It is recommended not to use sub-classes directly. There are factory methods for each item on super class. +Almost all methods on sealed classes use short names extracted from manifest method names. Full subclass names are not +used. It is recommended not to use subclasses directly. There are factory methods for each item on super class. ## Generic Usage @@ -371,8 +403,8 @@ abstract class _Basket { Sometimes you need some fields to be present in all of your sealed classes. For example consider making a sealed class for different types of errors, and all of them are required to have `code` and `message`. It is very annoying to add -code and message to all of sealeds manually. Also if you have an error object you are unable to get its code or message -without using cast or match methods. Here you can use common fields. +code and message to all of sealed classes manually. Also, if you have an error object you are unable to get its code or +message without using cast or match methods. Here you can use common fields. To declare a common field you can add a getter or a final field to a manifest class, and it will automatically be added to all of your sealed classes. for example: @@ -397,9 +429,9 @@ abstract class _ApiError { You can also use a constructor in pair with final fields equivalently. -common fields are available on `ApiError` objects as well as it's sub-classes. +common fields are available on `ApiError` objects as well as its subclasses. -If you specify common fields in your seaeld classes it has no effect. for example: +If you specify common fields in your sealed classes it has no effect. for example: ```dart @Sealed() @@ -413,7 +445,7 @@ abstract class _Common { } ``` -You can use sub-class of common field type in sealed classes. For example: +You can use subclass of common field type in sealed classes. For example: ```dart @Sealed() diff --git a/sealed_annotations/example/common.sealed.dart b/sealed_annotations/example/common.sealed.dart index 9a1d9a12..ca480c99 100644 --- a/sealed_annotations/example/common.sealed.dart +++ b/sealed_annotations/example/common.sealed.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'common.dart'; diff --git a/sealed_annotations/example/hierarchy.sealed.dart b/sealed_annotations/example/hierarchy.sealed.dart index fd2a2379..b261e5ec 100644 --- a/sealed_annotations/example/hierarchy.sealed.dart +++ b/sealed_annotations/example/hierarchy.sealed.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'hierarchy.dart'; diff --git a/sealed_annotations/example/meta.sealed.dart b/sealed_annotations/example/meta.sealed.dart index c9206305..61f8176b 100644 --- a/sealed_annotations/example/meta.sealed.dart +++ b/sealed_annotations/example/meta.sealed.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'meta.dart'; diff --git a/sealed_annotations/example/mixed.sealed.dart b/sealed_annotations/example/mixed.sealed.dart index 714eed71..1a0e5359 100644 --- a/sealed_annotations/example/mixed.sealed.dart +++ b/sealed_annotations/example/mixed.sealed.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'mixed.dart'; diff --git a/sealed_annotations/example/result.sealed.dart b/sealed_annotations/example/result.sealed.dart index ac95b722..9efb653c 100644 --- a/sealed_annotations/example/result.sealed.dart +++ b/sealed_annotations/example/result.sealed.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'result.dart'; diff --git a/sealed_annotations/example/result_complex.sealed.dart b/sealed_annotations/example/result_complex.sealed.dart index ba2cbf4a..68425e32 100644 --- a/sealed_annotations/example/result_complex.sealed.dart +++ b/sealed_annotations/example/result_complex.sealed.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'result_complex.dart'; diff --git a/sealed_annotations/example/result_hierarchy.sealed.dart b/sealed_annotations/example/result_hierarchy.sealed.dart index f2c52cc7..9fcf44c2 100644 --- a/sealed_annotations/example/result_hierarchy.sealed.dart +++ b/sealed_annotations/example/result_hierarchy.sealed.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'result_hierarchy.dart'; diff --git a/sealed_annotations/example/weather.sealed.dart b/sealed_annotations/example/weather.sealed.dart index 313adf10..c4259ed6 100644 --- a/sealed_annotations/example/weather.sealed.dart +++ b/sealed_annotations/example/weather.sealed.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'weather.dart'; diff --git a/sealed_annotations/lib/src/annotations.dart b/sealed_annotations/lib/src/annotations.dart index c634838a..73c9f387 100644 --- a/sealed_annotations/lib/src/annotations.dart +++ b/sealed_annotations/lib/src/annotations.dart @@ -95,7 +95,7 @@ class SealedManifest { }) class WithType { /// type name. - /// for example "int?", "double" or "Result". + /// for example "int?", "double" or "Result\". final String type; const WithType(this.type); diff --git a/sealed_annotations/pubspec.yaml b/sealed_annotations/pubspec.yaml index 29984876..824ac936 100644 --- a/sealed_annotations/pubspec.yaml +++ b/sealed_annotations/pubspec.yaml @@ -1,12 +1,12 @@ name: sealed_annotations description: Dart and Flutter sealed or union class generator and annotations, with match methods and other utilities. -repository: https://github.com/6thsolution/dart_sealed/tree/master/sealed_annotations -homepage: https://github.com/6thsolution/dart_sealed +repository: https://github.com/FatulM/dart_sealed/tree/master/sealed_annotations +homepage: https://github.com/FatulM/dart_sealed -version: 1.13.0 +version: 2.0.0 environment: - sdk: '>=2.12.0 <3.0.0' + sdk: '>=2.12.0 <4.0.0' dependencies: meta: any @@ -16,5 +16,5 @@ dev_dependencies: lints: any test: any -# remove this on pub branch +# THIS IS NOT THE UPSTREAM REPOSITORY AND ONLY ACCESSIBLE THROUGH GIT: publish_to: 'none' diff --git a/sealed_generators/CHANGELOG.md b/sealed_generators/CHANGELOG.md index d51605c6..1fba92ae 100644 --- a/sealed_generators/CHANGELOG.md +++ b/sealed_generators/CHANGELOG.md @@ -1,3 +1,11 @@ +## 2.0.0 + +- TODO + +## 1.14.0 + +- Fixed some issues + ## 1.13.0 - Added referToManifest to source writer diff --git a/sealed_generators/LICENSE b/sealed_generators/LICENSE index 2018725d..e7e4d00c 100644 --- a/sealed_generators/LICENSE +++ b/sealed_generators/LICENSE @@ -1,5 +1,6 @@ MIT License +Copyright (c) 2025 Amirreza Madani Copyright (c) 2021 6thsolution Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/sealed_generators/README.md b/sealed_generators/README.md index 1f3ca4ee..cff7af66 100644 --- a/sealed_generators/README.md +++ b/sealed_generators/README.md @@ -1,16 +1,19 @@ # Dart Sealed Class Generator -[![build](https://img.shields.io/github/workflow/status/6thsolution/dart_sealed/Dart?label=build)](https://github.com/6thsolution/dart_sealed/actions/workflows/dart.yml) -[![build](https://img.shields.io/codecov/c/gh/6thsolution/dart_sealed?label=coverage)](https://codecov.io/gh/6thsolution/dart_sealed) -[![pub](https://img.shields.io/pub/v/sealed_annotations.svg?color=blue&label=sealed_annotations)](https://pub.dev/packages/sealed_annotations) -[![pub](https://img.shields.io/pub/v/sealed_generators.svg?color=blue&label=sealed_generators)](https://pub.dev/packages/sealed_generators) -[![pub](https://img.shields.io/pub/v/sealed_writer.svg?color=blue&label=sealed_writer)](https://pub.dev/packages/sealed_writer) +[![build](https://img.shields.io/github/actions/workflow/status/FatulM/dart_sealed/.github/workflows/dart.yml?branch=master&label=build)](https://github.com/FatulM/dart_sealed/actions/workflows/dart.yml) +[![build](https://img.shields.io/codecov/c/gh/FatulM/dart_sealed?label=coverage)](https://codecov.io/gh/FatulM/dart_sealed) +[![pub](https://img.shields.io/badge/sealed__annotations-v2.0.0-blue)](https://github.com/FatulM/dart_sealed/tree/master/sealed_annotations) +[![pub](https://img.shields.io/badge/sealed__generators-v2.0.0-blue)](https://github.com/FatulM/dart_sealed/tree/master/sealed_generators) +[![version](https://img.shields.io/badge/sealed__writer-v2.0.0-blue)](https://github.com/FatulM/dart_sealed/tree/master/sealed_writer) Generate sealed class hierarchy for Dart and Flutter. +**NOTE** that this is only a clone of the upstream git repository +which I have fixed some issues and updated some dependencies. + ## Features -* Generate sealed class with abstract super type and data sub-classes. +* Generate sealed class with abstract super type and data subclasses. * Static factory methods. for example `Result.success(data: 0)`. * Cast methods. for example `a.asSuccess`, `a.isSuccess` or `a.asSuccessOrNull`. * Three types of equality and hashCode generation : data (like kotlin data classes), identity and distinct. @@ -26,12 +29,41 @@ Generate sealed class hierarchy for Dart and Flutter. Add dependencies in your `pubspec.yaml` file. +Since this is not the original repository, you can not use like this: + +```yaml +# WON'T WORK LIKE THIS: +dependencies: + sealed_annotations: '2.0.0' + +dev_dependencies: + sealed_generators: '2.0.0' +``` + +Instead, use like this: + +This will override the three dependencies to be downloaded from git. + ```yaml dependencies: - sealed_annotations: ^latest.version + sealed_annotations: '2.0.0' dev_dependencies: - sealed_generators: ^latest.version + sealed_generators: '2.0.0' + +dependency_overrides: + sealed_annotations: + git: + url: https://github.com/FatulM/dart_sealed + path: sealed_annotations/ + sealed_writer: + git: + url: https://github.com/FatulM/dart_sealed + path: sealed_writer/ + sealed_generators: + git: + url: https://github.com/FatulM/dart_sealed + path: sealed_generators/ ``` Import `sealed_annotations`. @@ -163,14 +195,14 @@ class WeatherWindy extends Weather { Notes: -- Prefer using factories in super class instead of sub-class constructors. like `Whether.rainy()` instead +- Prefer using factories in super class instead of subclass constructors. like `Whether.rainy()` instead of `WhetherRainy()` - Minimize usage of cast methods, most of the time they can be replaced with a match method. ## Equality and generated class names You can choose between three types of equality using `@WithEquality(...)` annotation. Default equality is `data` if not -specified. This will become default equality for all sub-classes. You can change equality of each sub-class by using +specified. This will become default equality for all subclasses. You can change equality of each subclass by using this annotation on individual methods. Equality types: @@ -209,14 +241,14 @@ abstract class _Weather { ``` An abstract super class is generated with name equal to name of manifest class without the underline (here `Weather`). -Each method will become a sub-class. There should be at least one method. sub-class names are based on method name +Each method will become a subclass. There should be at least one method. subclass names are based on method name prefixed with super class name (for example `WeatherSunny`). Naming process can be tailored with use of `@WithPrefix` -and `@WithName` annotations. Each method argument will become a field in corresponding sub-class. Field names are equal +and `@WithName` annotations. Each method argument will become a field in corresponding subclass. Field names are equal to argument names and field types are equal to argument types or dynamic if not specified. Argument types can be overridden using `@WithType` annotation for example when type information is not available at build time. Note that you can have nullable and non-nullable fields. -To change prefix of sub-class names which by default is top class name, you can use `@WithPrefix` annotation. for +To change prefix of subclass names which by default is top class name, you can use `@WithPrefix` annotation. for example: ```dart @@ -228,9 +260,9 @@ abstract class _Weather { ``` Now `sunny` will be named `HelloSunny` instead of the default `WeatherSunny`. You can use `@WithPrefix('')` to remove -all prefix from sub-class names. +all prefix from subclass names. -To change sub-class names directly you can use `@WithName` annotation. It will override `WithPrefix` if specified. for +To change subclass names directly you can use `@WithName` annotation. It will override `WithPrefix` if specified. for example: ```dart @@ -244,8 +276,8 @@ abstract class _Weather { Now `sunny` will be named `Hello` instead of the default `WeatherSunny`. This is useful if you want not to use prefix for some items. -Almost all methods on sealed classes use short names extracted from manifest method names. Full sub-class names are not -used. It is recommended not to use sub-classes directly. There are factory methods for each item on super class. +Almost all methods on sealed classes use short names extracted from manifest method names. Full subclass names are not +used. It is recommended not to use subclasses directly. There are factory methods for each item on super class. ## Generic Usage @@ -371,8 +403,8 @@ abstract class _Basket { Sometimes you need some fields to be present in all of your sealed classes. For example consider making a sealed class for different types of errors, and all of them are required to have `code` and `message`. It is very annoying to add -code and message to all of sealeds manually. Also if you have an error object you are unable to get its code or message -without using cast or match methods. Here you can use common fields. +code and message to all of sealed classes manually. Also, if you have an error object you are unable to get its code or +message without using cast or match methods. Here you can use common fields. To declare a common field you can add a getter or a final field to a manifest class, and it will automatically be added to all of your sealed classes. for example: @@ -397,9 +429,9 @@ abstract class _ApiError { You can also use a constructor in pair with final fields equivalently. -common fields are available on `ApiError` objects as well as it's sub-classes. +common fields are available on `ApiError` objects as well as its subclasses. -If you specify common fields in your seaeld classes it has no effect. for example: +If you specify common fields in your sealed classes it has no effect. for example: ```dart @Sealed() @@ -413,7 +445,7 @@ abstract class _Common { } ``` -You can use sub-class of common field type in sealed classes. For example: +You can use subclass of common field type in sealed classes. For example: ```dart @Sealed() diff --git a/sealed_generators/analysis_options.yaml b/sealed_generators/analysis_options.yaml index 7d7c0831..939066c4 100644 --- a/sealed_generators/analysis_options.yaml +++ b/sealed_generators/analysis_options.yaml @@ -1,6 +1,8 @@ include: package:lints/recommended.yaml analyzer: - strong-mode: - implicit-dynamic: false - implicit-casts: false + language: + strict-casts: true + strict-inference: true + strict-raw-types: true + diff --git a/sealed_generators/example/README.md b/sealed_generators/example/README.md index 1f3ca4ee..cff7af66 100644 --- a/sealed_generators/example/README.md +++ b/sealed_generators/example/README.md @@ -1,16 +1,19 @@ # Dart Sealed Class Generator -[![build](https://img.shields.io/github/workflow/status/6thsolution/dart_sealed/Dart?label=build)](https://github.com/6thsolution/dart_sealed/actions/workflows/dart.yml) -[![build](https://img.shields.io/codecov/c/gh/6thsolution/dart_sealed?label=coverage)](https://codecov.io/gh/6thsolution/dart_sealed) -[![pub](https://img.shields.io/pub/v/sealed_annotations.svg?color=blue&label=sealed_annotations)](https://pub.dev/packages/sealed_annotations) -[![pub](https://img.shields.io/pub/v/sealed_generators.svg?color=blue&label=sealed_generators)](https://pub.dev/packages/sealed_generators) -[![pub](https://img.shields.io/pub/v/sealed_writer.svg?color=blue&label=sealed_writer)](https://pub.dev/packages/sealed_writer) +[![build](https://img.shields.io/github/actions/workflow/status/FatulM/dart_sealed/.github/workflows/dart.yml?branch=master&label=build)](https://github.com/FatulM/dart_sealed/actions/workflows/dart.yml) +[![build](https://img.shields.io/codecov/c/gh/FatulM/dart_sealed?label=coverage)](https://codecov.io/gh/FatulM/dart_sealed) +[![pub](https://img.shields.io/badge/sealed__annotations-v2.0.0-blue)](https://github.com/FatulM/dart_sealed/tree/master/sealed_annotations) +[![pub](https://img.shields.io/badge/sealed__generators-v2.0.0-blue)](https://github.com/FatulM/dart_sealed/tree/master/sealed_generators) +[![version](https://img.shields.io/badge/sealed__writer-v2.0.0-blue)](https://github.com/FatulM/dart_sealed/tree/master/sealed_writer) Generate sealed class hierarchy for Dart and Flutter. +**NOTE** that this is only a clone of the upstream git repository +which I have fixed some issues and updated some dependencies. + ## Features -* Generate sealed class with abstract super type and data sub-classes. +* Generate sealed class with abstract super type and data subclasses. * Static factory methods. for example `Result.success(data: 0)`. * Cast methods. for example `a.asSuccess`, `a.isSuccess` or `a.asSuccessOrNull`. * Three types of equality and hashCode generation : data (like kotlin data classes), identity and distinct. @@ -26,12 +29,41 @@ Generate sealed class hierarchy for Dart and Flutter. Add dependencies in your `pubspec.yaml` file. +Since this is not the original repository, you can not use like this: + +```yaml +# WON'T WORK LIKE THIS: +dependencies: + sealed_annotations: '2.0.0' + +dev_dependencies: + sealed_generators: '2.0.0' +``` + +Instead, use like this: + +This will override the three dependencies to be downloaded from git. + ```yaml dependencies: - sealed_annotations: ^latest.version + sealed_annotations: '2.0.0' dev_dependencies: - sealed_generators: ^latest.version + sealed_generators: '2.0.0' + +dependency_overrides: + sealed_annotations: + git: + url: https://github.com/FatulM/dart_sealed + path: sealed_annotations/ + sealed_writer: + git: + url: https://github.com/FatulM/dart_sealed + path: sealed_writer/ + sealed_generators: + git: + url: https://github.com/FatulM/dart_sealed + path: sealed_generators/ ``` Import `sealed_annotations`. @@ -163,14 +195,14 @@ class WeatherWindy extends Weather { Notes: -- Prefer using factories in super class instead of sub-class constructors. like `Whether.rainy()` instead +- Prefer using factories in super class instead of subclass constructors. like `Whether.rainy()` instead of `WhetherRainy()` - Minimize usage of cast methods, most of the time they can be replaced with a match method. ## Equality and generated class names You can choose between three types of equality using `@WithEquality(...)` annotation. Default equality is `data` if not -specified. This will become default equality for all sub-classes. You can change equality of each sub-class by using +specified. This will become default equality for all subclasses. You can change equality of each subclass by using this annotation on individual methods. Equality types: @@ -209,14 +241,14 @@ abstract class _Weather { ``` An abstract super class is generated with name equal to name of manifest class without the underline (here `Weather`). -Each method will become a sub-class. There should be at least one method. sub-class names are based on method name +Each method will become a subclass. There should be at least one method. subclass names are based on method name prefixed with super class name (for example `WeatherSunny`). Naming process can be tailored with use of `@WithPrefix` -and `@WithName` annotations. Each method argument will become a field in corresponding sub-class. Field names are equal +and `@WithName` annotations. Each method argument will become a field in corresponding subclass. Field names are equal to argument names and field types are equal to argument types or dynamic if not specified. Argument types can be overridden using `@WithType` annotation for example when type information is not available at build time. Note that you can have nullable and non-nullable fields. -To change prefix of sub-class names which by default is top class name, you can use `@WithPrefix` annotation. for +To change prefix of subclass names which by default is top class name, you can use `@WithPrefix` annotation. for example: ```dart @@ -228,9 +260,9 @@ abstract class _Weather { ``` Now `sunny` will be named `HelloSunny` instead of the default `WeatherSunny`. You can use `@WithPrefix('')` to remove -all prefix from sub-class names. +all prefix from subclass names. -To change sub-class names directly you can use `@WithName` annotation. It will override `WithPrefix` if specified. for +To change subclass names directly you can use `@WithName` annotation. It will override `WithPrefix` if specified. for example: ```dart @@ -244,8 +276,8 @@ abstract class _Weather { Now `sunny` will be named `Hello` instead of the default `WeatherSunny`. This is useful if you want not to use prefix for some items. -Almost all methods on sealed classes use short names extracted from manifest method names. Full sub-class names are not -used. It is recommended not to use sub-classes directly. There are factory methods for each item on super class. +Almost all methods on sealed classes use short names extracted from manifest method names. Full subclass names are not +used. It is recommended not to use subclasses directly. There are factory methods for each item on super class. ## Generic Usage @@ -371,8 +403,8 @@ abstract class _Basket { Sometimes you need some fields to be present in all of your sealed classes. For example consider making a sealed class for different types of errors, and all of them are required to have `code` and `message`. It is very annoying to add -code and message to all of sealeds manually. Also if you have an error object you are unable to get its code or message -without using cast or match methods. Here you can use common fields. +code and message to all of sealed classes manually. Also, if you have an error object you are unable to get its code or +message without using cast or match methods. Here you can use common fields. To declare a common field you can add a getter or a final field to a manifest class, and it will automatically be added to all of your sealed classes. for example: @@ -397,9 +429,9 @@ abstract class _ApiError { You can also use a constructor in pair with final fields equivalently. -common fields are available on `ApiError` objects as well as it's sub-classes. +common fields are available on `ApiError` objects as well as its subclasses. -If you specify common fields in your seaeld classes it has no effect. for example: +If you specify common fields in your sealed classes it has no effect. for example: ```dart @Sealed() @@ -413,7 +445,7 @@ abstract class _Common { } ``` -You can use sub-class of common field type in sealed classes. For example: +You can use subclass of common field type in sealed classes. For example: ```dart @Sealed() diff --git a/sealed_generators/example/common.sealed.dart b/sealed_generators/example/common.sealed.dart index 9a1d9a12..ca480c99 100644 --- a/sealed_generators/example/common.sealed.dart +++ b/sealed_generators/example/common.sealed.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'common.dart'; diff --git a/sealed_generators/example/hierarchy.sealed.dart b/sealed_generators/example/hierarchy.sealed.dart index fd2a2379..b261e5ec 100644 --- a/sealed_generators/example/hierarchy.sealed.dart +++ b/sealed_generators/example/hierarchy.sealed.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'hierarchy.dart'; diff --git a/sealed_generators/example/meta.sealed.dart b/sealed_generators/example/meta.sealed.dart index c9206305..61f8176b 100644 --- a/sealed_generators/example/meta.sealed.dart +++ b/sealed_generators/example/meta.sealed.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'meta.dart'; diff --git a/sealed_generators/example/mixed.sealed.dart b/sealed_generators/example/mixed.sealed.dart index 714eed71..1a0e5359 100644 --- a/sealed_generators/example/mixed.sealed.dart +++ b/sealed_generators/example/mixed.sealed.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'mixed.dart'; diff --git a/sealed_generators/example/result.sealed.dart b/sealed_generators/example/result.sealed.dart index ac95b722..9efb653c 100644 --- a/sealed_generators/example/result.sealed.dart +++ b/sealed_generators/example/result.sealed.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'result.dart'; diff --git a/sealed_generators/example/result_complex.sealed.dart b/sealed_generators/example/result_complex.sealed.dart index ba2cbf4a..68425e32 100644 --- a/sealed_generators/example/result_complex.sealed.dart +++ b/sealed_generators/example/result_complex.sealed.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'result_complex.dart'; diff --git a/sealed_generators/example/result_hierarchy.sealed.dart b/sealed_generators/example/result_hierarchy.sealed.dart index f2c52cc7..9fcf44c2 100644 --- a/sealed_generators/example/result_hierarchy.sealed.dart +++ b/sealed_generators/example/result_hierarchy.sealed.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'result_hierarchy.dart'; diff --git a/sealed_generators/example/weather.sealed.dart b/sealed_generators/example/weather.sealed.dart index 313adf10..c4259ed6 100644 --- a/sealed_generators/example/weather.sealed.dart +++ b/sealed_generators/example/weather.sealed.dart @@ -1,3 +1,4 @@ +// dart format width=80 // GENERATED CODE - DO NOT MODIFY BY HAND part of 'weather.dart'; diff --git a/sealed_generators/lib/src/manifest/manifest_reader_builder.dart b/sealed_generators/lib/src/manifest/manifest_reader_builder.dart index 949fb203..45ebb387 100644 --- a/sealed_generators/lib/src/manifest/manifest_reader_builder.dart +++ b/sealed_generators/lib/src/manifest/manifest_reader_builder.dart @@ -37,7 +37,7 @@ class ManifestReaderBuilder { ); final cls = e as ClassElement; require( - !(e is EnumElement) && !(e is MixinElement) && !cls.isMixinApplication, + (e is! EnumElement) && (e is! MixinElement) && !cls.isMixinApplication, 'element should be a Class', ); require( diff --git a/sealed_generators/pubspec.yaml b/sealed_generators/pubspec.yaml index 3ed3abea..83459367 100644 --- a/sealed_generators/pubspec.yaml +++ b/sealed_generators/pubspec.yaml @@ -1,18 +1,16 @@ name: sealed_generators description: Dart and Flutter sealed or union class generator and annotations, with match methods and other utilities. -repository: https://github.com/6thsolution/dart_sealed/tree/master/sealed_generators -homepage: https://github.com/6thsolution/dart_sealed +repository: https://github.com/FatulM/dart_sealed/tree/master/sealed_generators +homepage: https://github.com/FatulM/dart_sealed -version: 1.13.0 +version: 2.0.0 environment: - sdk: '>=2.12.0 <3.0.0' + sdk: '>=2.12.0 <4.0.0' dependencies: - # use fixed version dependency - sealed_annotations: '1.13.0' - # use fixed version dependency - sealed_writer: '1.13.0' + sealed_annotations: '2.0.0' + sealed_writer: '2.0.0' build: any source_gen: any analyzer: any @@ -23,10 +21,10 @@ dev_dependencies: test: any build_test: any -# remove this on pub branch +# THIS IS NOT THE UPSTREAM REPOSITORY AND ONLY ACCESSIBLE THROUGH GIT: publish_to: 'none' -# remove this on pub branch +# THIS SHOULD BE OVERRIDDEN IN YOUR OWN PROJECTS: dependency_overrides: sealed_annotations: path: ../sealed_annotations diff --git a/sealed_writer/CHANGELOG.md b/sealed_writer/CHANGELOG.md index d51605c6..1fba92ae 100644 --- a/sealed_writer/CHANGELOG.md +++ b/sealed_writer/CHANGELOG.md @@ -1,3 +1,11 @@ +## 2.0.0 + +- TODO + +## 1.14.0 + +- Fixed some issues + ## 1.13.0 - Added referToManifest to source writer diff --git a/sealed_writer/LICENSE b/sealed_writer/LICENSE index 2018725d..e7e4d00c 100644 --- a/sealed_writer/LICENSE +++ b/sealed_writer/LICENSE @@ -1,5 +1,6 @@ MIT License +Copyright (c) 2025 Amirreza Madani Copyright (c) 2021 6thsolution Permission is hereby granted, free of charge, to any person obtaining a copy diff --git a/sealed_writer/README.md b/sealed_writer/README.md index 1f3ca4ee..cff7af66 100644 --- a/sealed_writer/README.md +++ b/sealed_writer/README.md @@ -1,16 +1,19 @@ # Dart Sealed Class Generator -[![build](https://img.shields.io/github/workflow/status/6thsolution/dart_sealed/Dart?label=build)](https://github.com/6thsolution/dart_sealed/actions/workflows/dart.yml) -[![build](https://img.shields.io/codecov/c/gh/6thsolution/dart_sealed?label=coverage)](https://codecov.io/gh/6thsolution/dart_sealed) -[![pub](https://img.shields.io/pub/v/sealed_annotations.svg?color=blue&label=sealed_annotations)](https://pub.dev/packages/sealed_annotations) -[![pub](https://img.shields.io/pub/v/sealed_generators.svg?color=blue&label=sealed_generators)](https://pub.dev/packages/sealed_generators) -[![pub](https://img.shields.io/pub/v/sealed_writer.svg?color=blue&label=sealed_writer)](https://pub.dev/packages/sealed_writer) +[![build](https://img.shields.io/github/actions/workflow/status/FatulM/dart_sealed/.github/workflows/dart.yml?branch=master&label=build)](https://github.com/FatulM/dart_sealed/actions/workflows/dart.yml) +[![build](https://img.shields.io/codecov/c/gh/FatulM/dart_sealed?label=coverage)](https://codecov.io/gh/FatulM/dart_sealed) +[![pub](https://img.shields.io/badge/sealed__annotations-v2.0.0-blue)](https://github.com/FatulM/dart_sealed/tree/master/sealed_annotations) +[![pub](https://img.shields.io/badge/sealed__generators-v2.0.0-blue)](https://github.com/FatulM/dart_sealed/tree/master/sealed_generators) +[![version](https://img.shields.io/badge/sealed__writer-v2.0.0-blue)](https://github.com/FatulM/dart_sealed/tree/master/sealed_writer) Generate sealed class hierarchy for Dart and Flutter. +**NOTE** that this is only a clone of the upstream git repository +which I have fixed some issues and updated some dependencies. + ## Features -* Generate sealed class with abstract super type and data sub-classes. +* Generate sealed class with abstract super type and data subclasses. * Static factory methods. for example `Result.success(data: 0)`. * Cast methods. for example `a.asSuccess`, `a.isSuccess` or `a.asSuccessOrNull`. * Three types of equality and hashCode generation : data (like kotlin data classes), identity and distinct. @@ -26,12 +29,41 @@ Generate sealed class hierarchy for Dart and Flutter. Add dependencies in your `pubspec.yaml` file. +Since this is not the original repository, you can not use like this: + +```yaml +# WON'T WORK LIKE THIS: +dependencies: + sealed_annotations: '2.0.0' + +dev_dependencies: + sealed_generators: '2.0.0' +``` + +Instead, use like this: + +This will override the three dependencies to be downloaded from git. + ```yaml dependencies: - sealed_annotations: ^latest.version + sealed_annotations: '2.0.0' dev_dependencies: - sealed_generators: ^latest.version + sealed_generators: '2.0.0' + +dependency_overrides: + sealed_annotations: + git: + url: https://github.com/FatulM/dart_sealed + path: sealed_annotations/ + sealed_writer: + git: + url: https://github.com/FatulM/dart_sealed + path: sealed_writer/ + sealed_generators: + git: + url: https://github.com/FatulM/dart_sealed + path: sealed_generators/ ``` Import `sealed_annotations`. @@ -163,14 +195,14 @@ class WeatherWindy extends Weather { Notes: -- Prefer using factories in super class instead of sub-class constructors. like `Whether.rainy()` instead +- Prefer using factories in super class instead of subclass constructors. like `Whether.rainy()` instead of `WhetherRainy()` - Minimize usage of cast methods, most of the time they can be replaced with a match method. ## Equality and generated class names You can choose between three types of equality using `@WithEquality(...)` annotation. Default equality is `data` if not -specified. This will become default equality for all sub-classes. You can change equality of each sub-class by using +specified. This will become default equality for all subclasses. You can change equality of each subclass by using this annotation on individual methods. Equality types: @@ -209,14 +241,14 @@ abstract class _Weather { ``` An abstract super class is generated with name equal to name of manifest class without the underline (here `Weather`). -Each method will become a sub-class. There should be at least one method. sub-class names are based on method name +Each method will become a subclass. There should be at least one method. subclass names are based on method name prefixed with super class name (for example `WeatherSunny`). Naming process can be tailored with use of `@WithPrefix` -and `@WithName` annotations. Each method argument will become a field in corresponding sub-class. Field names are equal +and `@WithName` annotations. Each method argument will become a field in corresponding subclass. Field names are equal to argument names and field types are equal to argument types or dynamic if not specified. Argument types can be overridden using `@WithType` annotation for example when type information is not available at build time. Note that you can have nullable and non-nullable fields. -To change prefix of sub-class names which by default is top class name, you can use `@WithPrefix` annotation. for +To change prefix of subclass names which by default is top class name, you can use `@WithPrefix` annotation. for example: ```dart @@ -228,9 +260,9 @@ abstract class _Weather { ``` Now `sunny` will be named `HelloSunny` instead of the default `WeatherSunny`. You can use `@WithPrefix('')` to remove -all prefix from sub-class names. +all prefix from subclass names. -To change sub-class names directly you can use `@WithName` annotation. It will override `WithPrefix` if specified. for +To change subclass names directly you can use `@WithName` annotation. It will override `WithPrefix` if specified. for example: ```dart @@ -244,8 +276,8 @@ abstract class _Weather { Now `sunny` will be named `Hello` instead of the default `WeatherSunny`. This is useful if you want not to use prefix for some items. -Almost all methods on sealed classes use short names extracted from manifest method names. Full sub-class names are not -used. It is recommended not to use sub-classes directly. There are factory methods for each item on super class. +Almost all methods on sealed classes use short names extracted from manifest method names. Full subclass names are not +used. It is recommended not to use subclasses directly. There are factory methods for each item on super class. ## Generic Usage @@ -371,8 +403,8 @@ abstract class _Basket { Sometimes you need some fields to be present in all of your sealed classes. For example consider making a sealed class for different types of errors, and all of them are required to have `code` and `message`. It is very annoying to add -code and message to all of sealeds manually. Also if you have an error object you are unable to get its code or message -without using cast or match methods. Here you can use common fields. +code and message to all of sealed classes manually. Also, if you have an error object you are unable to get its code or +message without using cast or match methods. Here you can use common fields. To declare a common field you can add a getter or a final field to a manifest class, and it will automatically be added to all of your sealed classes. for example: @@ -397,9 +429,9 @@ abstract class _ApiError { You can also use a constructor in pair with final fields equivalently. -common fields are available on `ApiError` objects as well as it's sub-classes. +common fields are available on `ApiError` objects as well as its subclasses. -If you specify common fields in your seaeld classes it has no effect. for example: +If you specify common fields in your sealed classes it has no effect. for example: ```dart @Sealed() @@ -413,7 +445,7 @@ abstract class _Common { } ``` -You can use sub-class of common field type in sealed classes. For example: +You can use subclass of common field type in sealed classes. For example: ```dart @Sealed() diff --git a/sealed_writer/analysis_options.yaml b/sealed_writer/analysis_options.yaml index 7d7c0831..939066c4 100644 --- a/sealed_writer/analysis_options.yaml +++ b/sealed_writer/analysis_options.yaml @@ -1,6 +1,8 @@ include: package:lints/recommended.yaml analyzer: - strong-mode: - implicit-dynamic: false - implicit-casts: false + language: + strict-casts: true + strict-inference: true + strict-raw-types: true + diff --git a/sealed_writer/example/README.md b/sealed_writer/example/README.md index 1f3ca4ee..cff7af66 100644 --- a/sealed_writer/example/README.md +++ b/sealed_writer/example/README.md @@ -1,16 +1,19 @@ # Dart Sealed Class Generator -[![build](https://img.shields.io/github/workflow/status/6thsolution/dart_sealed/Dart?label=build)](https://github.com/6thsolution/dart_sealed/actions/workflows/dart.yml) -[![build](https://img.shields.io/codecov/c/gh/6thsolution/dart_sealed?label=coverage)](https://codecov.io/gh/6thsolution/dart_sealed) -[![pub](https://img.shields.io/pub/v/sealed_annotations.svg?color=blue&label=sealed_annotations)](https://pub.dev/packages/sealed_annotations) -[![pub](https://img.shields.io/pub/v/sealed_generators.svg?color=blue&label=sealed_generators)](https://pub.dev/packages/sealed_generators) -[![pub](https://img.shields.io/pub/v/sealed_writer.svg?color=blue&label=sealed_writer)](https://pub.dev/packages/sealed_writer) +[![build](https://img.shields.io/github/actions/workflow/status/FatulM/dart_sealed/.github/workflows/dart.yml?branch=master&label=build)](https://github.com/FatulM/dart_sealed/actions/workflows/dart.yml) +[![build](https://img.shields.io/codecov/c/gh/FatulM/dart_sealed?label=coverage)](https://codecov.io/gh/FatulM/dart_sealed) +[![pub](https://img.shields.io/badge/sealed__annotations-v2.0.0-blue)](https://github.com/FatulM/dart_sealed/tree/master/sealed_annotations) +[![pub](https://img.shields.io/badge/sealed__generators-v2.0.0-blue)](https://github.com/FatulM/dart_sealed/tree/master/sealed_generators) +[![version](https://img.shields.io/badge/sealed__writer-v2.0.0-blue)](https://github.com/FatulM/dart_sealed/tree/master/sealed_writer) Generate sealed class hierarchy for Dart and Flutter. +**NOTE** that this is only a clone of the upstream git repository +which I have fixed some issues and updated some dependencies. + ## Features -* Generate sealed class with abstract super type and data sub-classes. +* Generate sealed class with abstract super type and data subclasses. * Static factory methods. for example `Result.success(data: 0)`. * Cast methods. for example `a.asSuccess`, `a.isSuccess` or `a.asSuccessOrNull`. * Three types of equality and hashCode generation : data (like kotlin data classes), identity and distinct. @@ -26,12 +29,41 @@ Generate sealed class hierarchy for Dart and Flutter. Add dependencies in your `pubspec.yaml` file. +Since this is not the original repository, you can not use like this: + +```yaml +# WON'T WORK LIKE THIS: +dependencies: + sealed_annotations: '2.0.0' + +dev_dependencies: + sealed_generators: '2.0.0' +``` + +Instead, use like this: + +This will override the three dependencies to be downloaded from git. + ```yaml dependencies: - sealed_annotations: ^latest.version + sealed_annotations: '2.0.0' dev_dependencies: - sealed_generators: ^latest.version + sealed_generators: '2.0.0' + +dependency_overrides: + sealed_annotations: + git: + url: https://github.com/FatulM/dart_sealed + path: sealed_annotations/ + sealed_writer: + git: + url: https://github.com/FatulM/dart_sealed + path: sealed_writer/ + sealed_generators: + git: + url: https://github.com/FatulM/dart_sealed + path: sealed_generators/ ``` Import `sealed_annotations`. @@ -163,14 +195,14 @@ class WeatherWindy extends Weather { Notes: -- Prefer using factories in super class instead of sub-class constructors. like `Whether.rainy()` instead +- Prefer using factories in super class instead of subclass constructors. like `Whether.rainy()` instead of `WhetherRainy()` - Minimize usage of cast methods, most of the time they can be replaced with a match method. ## Equality and generated class names You can choose between three types of equality using `@WithEquality(...)` annotation. Default equality is `data` if not -specified. This will become default equality for all sub-classes. You can change equality of each sub-class by using +specified. This will become default equality for all subclasses. You can change equality of each subclass by using this annotation on individual methods. Equality types: @@ -209,14 +241,14 @@ abstract class _Weather { ``` An abstract super class is generated with name equal to name of manifest class without the underline (here `Weather`). -Each method will become a sub-class. There should be at least one method. sub-class names are based on method name +Each method will become a subclass. There should be at least one method. subclass names are based on method name prefixed with super class name (for example `WeatherSunny`). Naming process can be tailored with use of `@WithPrefix` -and `@WithName` annotations. Each method argument will become a field in corresponding sub-class. Field names are equal +and `@WithName` annotations. Each method argument will become a field in corresponding subclass. Field names are equal to argument names and field types are equal to argument types or dynamic if not specified. Argument types can be overridden using `@WithType` annotation for example when type information is not available at build time. Note that you can have nullable and non-nullable fields. -To change prefix of sub-class names which by default is top class name, you can use `@WithPrefix` annotation. for +To change prefix of subclass names which by default is top class name, you can use `@WithPrefix` annotation. for example: ```dart @@ -228,9 +260,9 @@ abstract class _Weather { ``` Now `sunny` will be named `HelloSunny` instead of the default `WeatherSunny`. You can use `@WithPrefix('')` to remove -all prefix from sub-class names. +all prefix from subclass names. -To change sub-class names directly you can use `@WithName` annotation. It will override `WithPrefix` if specified. for +To change subclass names directly you can use `@WithName` annotation. It will override `WithPrefix` if specified. for example: ```dart @@ -244,8 +276,8 @@ abstract class _Weather { Now `sunny` will be named `Hello` instead of the default `WeatherSunny`. This is useful if you want not to use prefix for some items. -Almost all methods on sealed classes use short names extracted from manifest method names. Full sub-class names are not -used. It is recommended not to use sub-classes directly. There are factory methods for each item on super class. +Almost all methods on sealed classes use short names extracted from manifest method names. Full subclass names are not +used. It is recommended not to use subclasses directly. There are factory methods for each item on super class. ## Generic Usage @@ -371,8 +403,8 @@ abstract class _Basket { Sometimes you need some fields to be present in all of your sealed classes. For example consider making a sealed class for different types of errors, and all of them are required to have `code` and `message`. It is very annoying to add -code and message to all of sealeds manually. Also if you have an error object you are unable to get its code or message -without using cast or match methods. Here you can use common fields. +code and message to all of sealed classes manually. Also, if you have an error object you are unable to get its code or +message without using cast or match methods. Here you can use common fields. To declare a common field you can add a getter or a final field to a manifest class, and it will automatically be added to all of your sealed classes. for example: @@ -397,9 +429,9 @@ abstract class _ApiError { You can also use a constructor in pair with final fields equivalently. -common fields are available on `ApiError` objects as well as it's sub-classes. +common fields are available on `ApiError` objects as well as its subclasses. -If you specify common fields in your seaeld classes it has no effect. for example: +If you specify common fields in your sealed classes it has no effect. for example: ```dart @Sealed() @@ -413,7 +445,7 @@ abstract class _Common { } ``` -You can use sub-class of common field type in sealed classes. For example: +You can use subclass of common field type in sealed classes. For example: ```dart @Sealed() diff --git a/sealed_writer/lib/src/manifest/manifest_integrity.dart b/sealed_writer/lib/src/manifest/manifest_integrity.dart index a49b1e23..fba0a8e7 100644 --- a/sealed_writer/lib/src/manifest/manifest_integrity.dart +++ b/sealed_writer/lib/src/manifest/manifest_integrity.dart @@ -102,7 +102,7 @@ void _checkMatchNames(Manifest manifest) { for (final item in manifest.items) { [ ..._matchNames, - ...item.fields.map(_fieldName).toList(), + ...item.fields.map(_fieldName), ].checkNoEquals(); } } diff --git a/sealed_writer/lib/src/utils/string_utils.dart b/sealed_writer/lib/src/utils/string_utils.dart index a5f540e9..2aedd693 100644 --- a/sealed_writer/lib/src/utils/string_utils.dart +++ b/sealed_writer/lib/src/utils/string_utils.dart @@ -7,7 +7,7 @@ extension StringIterableUtils on Iterable { } else if (length == 1) { return first; } else { - return join(', ') + ','; + return '${join(', ')},'; } } @@ -19,7 +19,7 @@ extension StringIterableUtils on Iterable { if (isEmpty) { return ''; } else { - return join(', ') + ','; + return '${join(', ')},'; } } diff --git a/sealed_writer/lib/src/writer/base/base_utils_writer.dart b/sealed_writer/lib/src/writer/base/base_utils_writer.dart index 7c954001..b9f9ed6c 100644 --- a/sealed_writer/lib/src/writer/base/base_utils_writer.dart +++ b/sealed_writer/lib/src/writer/base/base_utils_writer.dart @@ -45,30 +45,30 @@ abstract class BaseUtilsWriter extends BaseWriter { String genericDecPart(ManifestParam param) => '${param.name} extends ${typeSL(param.bound)}'; - /// ex. + /// ex. \ String get genericDec => manifest.params.map(genericDecPart).joinArgsSimple().withLtGtOrNot(); /// ex. T String genericCallPart(ManifestParam param) => param.name; - /// ex. + /// ex. \ String get genericCall => manifest.params.map(genericCallPart).joinArgsSimple().withLtGtOrNot(); /// top class name with params for declaration. - /// ex. Result or Weather + /// ex. Result\ or Weather String get topDec => '$top$genericDec'; /// top class name with params for call. - /// ex. Result or Weather + /// ex. Result\ or Weather String get topCall => '$top$genericCall'; /// sub class name with params for declaration. - /// ex. WeatherSunny or ResultSuccess + /// ex. WeatherSunny or ResultSuccess\ String subDec(ManifestItem item) => '${subFull(item)}$genericDec'; /// sub class name with params for call. - /// ex. WeatherSunny or ResultSuccess + /// ex. WeatherSunny or ResultSuccess\ String subCall(ManifestItem item) => '${subFull(item)}$genericCall'; } diff --git a/sealed_writer/lib/src/writer/sub/sub_equatable_writer.dart b/sealed_writer/lib/src/writer/sub/sub_equatable_writer.dart index aa2827df..0eac55f7 100644 --- a/sealed_writer/lib/src/writer/sub/sub_equatable_writer.dart +++ b/sealed_writer/lib/src/writer/sub/sub_equatable_writer.dart @@ -11,7 +11,7 @@ class SubEquatableWriter extends BaseUtilsWriter { Iterable subEquatableFieldNames(ManifestItem item) => item.fields.map(fieldName); - /// List get props => [a, b, ...]; + /// List\ get props => [a, b, ...]; String subEquatableEquality(ManifestItem item) => [ annotationOverride, [ diff --git a/sealed_writer/lib/src/writer/top/match/top_match_base_writer.dart b/sealed_writer/lib/src/writer/top/match/top_match_base_writer.dart index 8d82c527..96dc5f8b 100644 --- a/sealed_writer/lib/src/writer/top/match/top_match_base_writer.dart +++ b/sealed_writer/lib/src/writer/top/match/top_match_base_writer.dart @@ -7,7 +7,7 @@ import 'package:sealed_writer/src/writer/base/base_cast_utils_writer.dart'; class TopMatchBaseWriter extends BaseCastUtilsWriter { const TopMatchBaseWriter(Manifest manifest) : super(manifest); - /// + /// \ String get topMatchParam => ''; /// required (R Function(WeatherSunny sunny)) sunny diff --git a/sealed_writer/lib/src/writer/top/match/top_match_map_or_null_writer.dart b/sealed_writer/lib/src/writer/top/match/top_match_map_or_null_writer.dart index aa3c28af..7711429f 100644 --- a/sealed_writer/lib/src/writer/top/match/top_match_map_or_null_writer.dart +++ b/sealed_writer/lib/src/writer/top/match/top_match_map_or_null_writer.dart @@ -46,7 +46,7 @@ class TopMatchMapOrNullWriter extends TopMatchBaseWriter { topMatchMapOrNullArgs().joinArgsFull().withBraces().withParenthesis(), ].joinParts(); - /// R? mapOrNull(item..., orElse) {...} + /// R? mapOrNull\(item..., orElse) {...} String topMatchMapOrNull() => [ topMatchMapOrNullStart(), '{', diff --git a/sealed_writer/lib/src/writer/top/match/top_match_map_writer.dart b/sealed_writer/lib/src/writer/top/match/top_match_map_writer.dart index 50879227..8ad02b90 100644 --- a/sealed_writer/lib/src/writer/top/match/top_match_map_writer.dart +++ b/sealed_writer/lib/src/writer/top/match/top_match_map_writer.dart @@ -37,7 +37,7 @@ class TopMatchMapWriter extends TopMatchBaseWriter { topMatchMapArgs().joinArgsFull().withBraces().withParenthesis(), ].joinParts(); - /// R map(required item...) + /// R map\(required item...) /// {...} String topMatchMap() => [ topMatchMapStart(), diff --git a/sealed_writer/lib/src/writer/top/match/top_match_maybe_map_writer.dart b/sealed_writer/lib/src/writer/top/match/top_match_maybe_map_writer.dart index af619771..2651bab4 100644 --- a/sealed_writer/lib/src/writer/top/match/top_match_maybe_map_writer.dart +++ b/sealed_writer/lib/src/writer/top/match/top_match_maybe_map_writer.dart @@ -46,7 +46,7 @@ class TopMatchMaybeMapWriter extends TopMatchBaseWriter { topMatchMaybeMapArgs().joinArgsFull().withBraces().withParenthesis(), ].joinParts(); - /// R maybeMap(item..., required orElse) {...} + /// R maybeMap\(item..., required orElse) {...} String topMatchMaybeMap() => [ topMatchMaybeMapStart(), '{', diff --git a/sealed_writer/lib/src/writer/top/match/top_match_maybe_when_writer.dart b/sealed_writer/lib/src/writer/top/match/top_match_maybe_when_writer.dart index 59be6041..f8f8838c 100644 --- a/sealed_writer/lib/src/writer/top/match/top_match_maybe_when_writer.dart +++ b/sealed_writer/lib/src/writer/top/match/top_match_maybe_when_writer.dart @@ -46,7 +46,7 @@ class TopMatchMaybeWhenWriter extends TopMatchBaseWriter { topMatchMaybeWhenArgs().joinArgsFull().withBraces().withParenthesis(), ].joinParts(); - /// R maybeWhen(item..., required orElse) {...} + /// R maybeWhen\(item..., required orElse) {...} String topMatchMaybeWhen() => [ topMatchMaybeWhenStart(), '{', diff --git a/sealed_writer/lib/src/writer/top/match/top_match_when_or_null_writer.dart b/sealed_writer/lib/src/writer/top/match/top_match_when_or_null_writer.dart index 58d1a2fb..00b556d9 100644 --- a/sealed_writer/lib/src/writer/top/match/top_match_when_or_null_writer.dart +++ b/sealed_writer/lib/src/writer/top/match/top_match_when_or_null_writer.dart @@ -46,7 +46,7 @@ class TopMatchWhenOrNullWriter extends TopMatchBaseWriter { topMatchWhenOrNullArgs().joinArgsFull().withBraces().withParenthesis(), ].joinParts(); - /// R? whenOrNull(item..., orElse) {...} + /// R? whenOrNull\(item..., orElse) {...} String topMatchWhenOrNull() => [ topMatchWhenOrNullStart(), '{', diff --git a/sealed_writer/lib/src/writer/top/match/top_match_when_writer.dart b/sealed_writer/lib/src/writer/top/match/top_match_when_writer.dart index 90cbc619..914b4f4c 100644 --- a/sealed_writer/lib/src/writer/top/match/top_match_when_writer.dart +++ b/sealed_writer/lib/src/writer/top/match/top_match_when_writer.dart @@ -37,7 +37,7 @@ class TopMatchWhenWriter extends TopMatchBaseWriter { topMatchWhenArgs().joinArgsFull().withBraces().withParenthesis(), ].joinParts(); - /// R when(required item...) + /// R when\(required item...) /// {...} String topMatchWhen() => [ topMatchWhenStart(), diff --git a/sealed_writer/lib/src/writer/top/top_builder_writer.dart b/sealed_writer/lib/src/writer/top/top_builder_writer.dart index d86d4d2e..8c857748 100644 --- a/sealed_writer/lib/src/writer/top/top_builder_writer.dart +++ b/sealed_writer/lib/src/writer/top/top_builder_writer.dart @@ -47,8 +47,8 @@ class TopBuilderWriter extends BaseUtilsWriter { /// ex. static WeatherSunny sunny() => WeatherSunny(); /// - /// ex. static ResultSuccess success(...) => - /// ResultSuccess(...) + /// ex. static ResultSuccess\ \success(...) => + /// ResultSuccess\(...) String topStaticBuilder(ManifestItem item) => [ 'static ${subCall(item)} ${subLower(item)}$genericDec', topBuilderDecArgs(item), @@ -59,7 +59,7 @@ class TopBuilderWriter extends BaseUtilsWriter { /// ex. factory Weather.sunny() = WeatherSunny; /// - /// ex. factory Result.success(...) = ResultSuccess; + /// ex. factory Result.success(...) = ResultSuccess\; String topFactoryBuilder(ManifestItem item) => [ 'const factory $top.${subLower(item)}', topBuilderDecArgs(item), diff --git a/sealed_writer/pubspec.yaml b/sealed_writer/pubspec.yaml index b0689d6c..6a13278b 100644 --- a/sealed_writer/pubspec.yaml +++ b/sealed_writer/pubspec.yaml @@ -1,16 +1,16 @@ name: sealed_writer description: Dart and Flutter sealed or union class generator and annotations, with match methods and other utilities. -repository: https://github.com/6thsolution/dart_sealed/tree/master/sealed_writer -homepage: https://github.com/6thsolution/dart_sealed +repository: https://github.com/FatulM/dart_sealed/tree/master/sealed_writer +homepage: https://github.com/FatulM/dart_sealed -version: 1.13.0 +version: 2.0.0 environment: - sdk: '>=2.12.0 <3.0.0' + sdk: '>=2.12.0 <4.0.0' dev_dependencies: lints: any test: any -# remove this on pub branch +# THIS IS NOT THE UPSTREAM REPOSITORY AND ONLY ACCESSIBLE THROUGH GIT: publish_to: 'none'