6thsolution / dart_sealed

Dart and Flutter sealed class generator and annotations, with match methods and other utilities. There is also super_enum compatible API.
https://pub.dev/packages/sealed_annotations
MIT License
17 stars 9 forks source link

Support for nullable optional parameters #4

Closed payam-zahedi closed 3 years ago

payam-zahedi commented 3 years ago

After working with this package for a while, I have noticed that the package doesn't support for optional parameters. I think users will have a better experience if they do not have to submit optional parameters.

FatulM commented 3 years ago

HI, One way to implement this is to omit required from nullable arguments in constructors. What's your opinion ? @SaeedMasoumi

SaeedMasoumi commented 3 years ago

The generated file will be like from

 const factory State.success({
    required A a,
    required B? b,
  }) = StateSuccess;

to

 const factory State.success({
    required A a,
    B? b,
  }) = StateSuccess;

? It makes sense to be like the second form

payam-zahedi commented 3 years ago
 const factory State.success({
    required A a,
    B? b,
  }) = StateSuccess;

Yes, that make sense and has better experience.

payam-zahedi commented 3 years ago

Does the package also support Optional positional parameters? Something like this?

 void success(bool status, [ String? value]);
FatulM commented 3 years ago

So, I'll change implementation ASAP 😊

FatulM commented 3 years ago

Does the package also support Optional positional parameters? Something like this?

 void success(bool status, [ String? value]);

No, All of parameters are named ... Is this feature needed ?

payam-zahedi commented 3 years ago

It's not something I need, but others may need it.

FatulM commented 3 years ago

Hi, I've published version 1.9.0 which addresses your issue ...

payam-zahedi commented 3 years ago

That's awesome @FatulM, we can close this issue now.