Skip to content

Added new generate_to_json_function build option #230

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 8, 2018
Merged

Conversation

kevmoo
Copy link
Collaborator

@kevmoo kevmoo commented Jun 8, 2018

Controls how toJson functionality is generated for all types processed
by this generator.

If false (the default), a private _$ClassNameSerializerMixin class is
created in the generated part file which contains a toJson method.

Mix in this class to the source class:

@JsonSerializable()
class Example extends Object with _$ExampleSerializerMixin {
  // ...
}

If true, then a top-level function is created that you can reference
from your class.

@JsonSerializable()
class Example {
  // ...
  Map<String, dynamic> toJson() => _$ExampleToJson(this);
}

Controls how `toJson` functionality is generated for all types processed
by this generator.

If `false` (the default), a private `_$ClassNameSerializerMixin` class is
created in the generated part file which contains a `toJson` method.

Mix in this class to the source class:

```dart
@JsonSerializable()
class Example extends Object with _$ExampleSerializerMixin {
  // ...
}
```

If `true`, then a top-level function is created that you can reference
from your class.

```dart
@JsonSerializable()
class Example {
  // ...
  Map<String, dynamic> toJson() => _$ExampleToJson(this);
}
```
@kevmoo kevmoo requested a review from jakemac53 June 8, 2018 15:35
} else {
//
// Generate the mixin class
//
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

:D?

@kevmoo kevmoo merged commit 23d0f3d into master Jun 8, 2018
@kevmoo kevmoo deleted the toJsonFunction branch June 8, 2018 15:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants