Skip to content
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

core: Give JsonObject const constructor #1250

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions built_value/lib/json_object.dart
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ abstract class JsonObject {
}
}

JsonObject._();
const JsonObject._();
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we need const factories as well to make use of this private constructor?

Copy link
Author

Choose a reason for hiding this comment

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

What do you mean ? You would want the

factory JsonObject(Object? value) {

line 78 to be const?

It cannot be const as it has a body with if elses

Copy link
Contributor

Choose a reason for hiding this comment

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

I meant introducing multiple smaller factories, e.g.
const factory JsonObject.fromNum = NumJsonObject;

Copy link
Author

Choose a reason for hiding this comment

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

Oh okay! I'm okay with this, I guess we should see what @davidmorgan thinks about that


@override
String toString() {
Expand All @@ -88,7 +88,7 @@ class BoolJsonObject extends JsonObject {
@override
final bool value;

BoolJsonObject(this.value) : super._();
const BoolJsonObject(this.value) : super._();

@override
bool get isBool => true;
Expand Down Expand Up @@ -164,7 +164,7 @@ class NumJsonObject extends JsonObject {
@override
final num value;

NumJsonObject(this.value) : super._();
const NumJsonObject(this.value) : super._();

@override
bool get isNum => true;
Expand All @@ -188,7 +188,7 @@ class StringJsonObject extends JsonObject {
@override
final String value;

StringJsonObject(this.value) : super._();
const StringJsonObject(this.value) : super._();

@override
bool get isString => true;
Expand Down