Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion example/bin/example.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import 'sealed/nullsafe/data/generic/result_single_1.dart';
import 'sealed/nullsafe/data/simple/weather.dart';

void main() {
final a = Weather.sunny();
final a = Weather.sunny;
final b = Weather.rainy(rain: 12);
final c = Weather.windy(velocity: 1.5, angle: null);

Expand Down
8 changes: 4 additions & 4 deletions example/bin/sealed/nullsafe/data/simple/meta.sealed.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions example/bin/sealed/nullsafe/data/simple/weather.sealed.dart

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

20 changes: 14 additions & 6 deletions sealed_writer/lib/src/writer/top/top_builder_writer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -57,15 +57,23 @@ class TopBuilderWriter extends BaseUtilsWriter {
';',
].joinParts();

/// ex. factory Weather.sunny() = WeatherSunny;
/// ex. static const Weather sunny = WeatherSunny();
///
/// ex. factory Result.success(...) = ResultSuccess<T>;
String topFactoryBuilder(ManifestItem item) => [
'const factory $top.${subLower(item)}',
topBuilderDecArgs(item),
' = ',
subCall(item),
';',
if (item.fields.isNotEmpty) ...<String>[
'const factory $top.${subLower(item)}',
topBuilderDecArgs(item),
' = ',
subCall(item),
';',
],
if (item.fields.isEmpty) ...<String>[
'static const $top ${subLower(item)}',
' = ',
subCall(item),
'();',
]
].joinParts();

/// top builder methods
Expand Down