Skip to content

Commit e641871

Browse files
committed
Merge branch 'master' into pub
# Conflicts: # sealed_generators/pubspec.yaml
2 parents f4c623b + 1466ff2 commit e641871

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+328
-303
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 1.6.0
2+
3+
- Changed cast methods to getters
4+
- Downgrade meta to 1.3.0
5+
16
## 1.5.0
27

38
- Removed support for super_enum API

README.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Generate sealed class hierarchy for Dart and Flutter.
1212

1313
* Generate sealed class with abstract super type and data sub-classes.
1414
* Static factory methods. for example `Result.success(data: 0)`.
15-
* Cast methods. for example `a.asSuccess()`, `a.isSuccess()` or `a.asSuccessOrNull()`.
15+
* Cast methods. for example `a.asSuccess`, `a.isSuccess` or `a.asSuccessOrNull`.
1616
* Three types of equality and hashCode generation : data (like kotlin data classes), identity and distinct.
1717
* Implement data equality with popular equatable library.
1818
* Support for generics. even types can be mixed.
@@ -40,7 +40,7 @@ Import `sealed_annotations`.
4040
import 'package:sealed_annotations/sealed_annotations.dart';
4141
```
4242

43-
Add `part` pointing to a file which you want classes be generated in. with `.super.dart` extension.
43+
Add `part` pointing to a file which you want classes be generated in. with `.sealed.dart` extension.
4444

4545
```dart
4646
part 'weather.sealed.dart';
@@ -71,11 +71,11 @@ The generated code will look like: (the following code is summarised)
7171
abstract class Weather {
7272
const factory Weather.rainy({required int rain}) = WeatherRainy;
7373
74-
bool isRainy() => this is WeatherRainy;
74+
bool get isRainy => this is WeatherRainy;
7575
76-
WeatherRainy asRainy() => this as WeatherRainy;
76+
WeatherRainy get asRainy => this as WeatherRainy;
7777
78-
WeatherRainy? asRainyOrNull() {
78+
WeatherRainy? get asRainyOrNull {
7979
/* ... */
8080
}
8181
@@ -157,7 +157,7 @@ class WeatherWindy extends Weather {
157157

158158
Notes:
159159

160-
- Prefer using factories in super class instead of sub-class constructors.
160+
- Prefer using factories in super class instead of sub-class constructors. like `Whether.rainy()` instead of `WhetherRainy()`
161161
- Minimize usage of cast methods, most of the time they can be replaced with a match method.
162162

163163
## Equality and generated class names

sealed_annotations/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 1.6.0
2+
3+
- Changed cast methods to getters
4+
- Downgrade meta to 1.3.0
5+
16
## 1.5.0
27

38
- Removed support for super_enum API

sealed_annotations/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Generate sealed class hierarchy for Dart and Flutter.
1212

1313
* Generate sealed class with abstract super type and data sub-classes.
1414
* Static factory methods. for example `Result.success(data: 0)`.
15-
* Cast methods. for example `a.asSuccess()`, `a.isSuccess()` or `a.asSuccessOrNull()`.
15+
* Cast methods. for example `a.asSuccess`, `a.isSuccess` or `a.asSuccessOrNull`.
1616
* Three types of equality and hashCode generation : data (like kotlin data classes), identity and distinct.
1717
* Implement data equality with popular equatable library.
1818
* Support for generics. even types can be mixed.
@@ -71,11 +71,11 @@ The generated code will look like: (the following code is summarised)
7171
abstract class Weather {
7272
const factory Weather.rainy({required int rain}) = WeatherRainy;
7373
74-
bool isRainy() => this is WeatherRainy;
74+
bool get isRainy => this is WeatherRainy;
7575
76-
WeatherRainy asRainy() => this as WeatherRainy;
76+
WeatherRainy get asRainy => this as WeatherRainy;
7777
78-
WeatherRainy? asRainyOrNull() {
78+
WeatherRainy? get asRainyOrNull {
7979
/* ... */
8080
}
8181

sealed_annotations/example/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ Generate sealed class hierarchy for Dart and Flutter.
1212

1313
* Generate sealed class with abstract super type and data sub-classes.
1414
* Static factory methods. for example `Result.success(data: 0)`.
15-
* Cast methods. for example `a.asSuccess()`, `a.isSuccess()` or `a.asSuccessOrNull()`.
15+
* Cast methods. for example `a.asSuccess`, `a.isSuccess` or `a.asSuccessOrNull`.
1616
* Three types of equality and hashCode generation : data (like kotlin data classes), identity and distinct.
1717
* Implement data equality with popular equatable library.
1818
* Support for generics. even types can be mixed.
@@ -71,11 +71,11 @@ The generated code will look like: (the following code is summarised)
7171
abstract class Weather {
7272
const factory Weather.rainy({required int rain}) = WeatherRainy;
7373
74-
bool isRainy() => this is WeatherRainy;
74+
bool get isRainy => this is WeatherRainy;
7575
76-
WeatherRainy asRainy() => this as WeatherRainy;
76+
WeatherRainy get asRainy => this as WeatherRainy;
7777
78-
WeatherRainy? asRainyOrNull() {
78+
WeatherRainy? get asRainyOrNull {
7979
/* ... */
8080
}
8181

sealed_annotations/example/meta.sealed.dart

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sealed_annotations/example/mixed.sealed.dart

Lines changed: 15 additions & 15 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sealed_annotations/example/result.sealed.dart

Lines changed: 6 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sealed_annotations/example/result_complex.sealed.dart

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sealed_annotations/example/weather.sealed.dart

Lines changed: 9 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)