jankuss / genq

Instant Data Class Generation for Dart
MIT License
133 stars 0 forks source link

Support for const factory #23

Closed BWhiteApps closed 4 months ago

BWhiteApps commented 4 months ago

Awesome package! Could you adjust it to support const factory constructors?

Ex:

@Genq(json: true)
class User with _$User {
  const factory User({
    @JsonKey(
      fromJson: UserName.fromJson,
      toJson: UserName.toJson,
    )
    required UserName name,
    required int age,
  }) = _User;
}

Thanks!

jankuss commented 4 months ago

Yeah, we should support this, and it is not a big change. We just have to mark the generated constructor as const as well. I implemented this in the following PR: #24 - expect it to be merged this weekend.

Once it is merged I will create a new release.

jankuss commented 4 months ago

@BWhiteApps support for const factory constructors has been released in 0.4.0

You can run the following command to get the latest version of genq:

brew upgrade jankuss/genq/genq
BWhiteApps commented 4 months ago

Awesome thanks