You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Pigeon] bool type as a parameter generates unusable dart code #62463
And it isn't just the dart code, I see the same in generated JVM code as well and I assume in the Objective-C code as well.
So it looks like you only support passing classes as parameters. Which if that is the direction you want to go then it should generate an error not generate unusable code.
I contemplated forking to add this and a bunch of other missing things or
improvements. As I later learned return values are the same.
Here is my issues with it, not sure if all are possible:
- Parameters cannot be non-classes
- Return values cannot be non-classes
- Only supports 1 parameter
- Generates Java and Obj-C not kotlin or swift
- Generated classes are very primitive (mutable, no builder, no toString,
no equality)
- Would be nice to specify default values for class members
- The Java code for calling flutter APIs requires supplying a callback to
handle return value which you may not care about.
Would be nice if there was a templating mechanism where a user could
specify their own template files to customize the generated code. This is
what openApiGenerator does using moustache templates, but unfortunately
there is no good templating mechanism for dart (mustache4dart is nowhere
near as powerful as the real mustache engine)
Note I had found mustache4dart and i thought was not powerful enough, but according to the site it passes all the specification tests so I may have dismissed it too quickly. I since discovered a different mustache dart library that should also do the trick.
Another feature I would like is the ability to support not having to use command line parameters. You have the configuration method that can do most of it, but that only works if you specify input parameter. So I am thinking of perhaps you look for a pigeon_config.dart and include it and/or look for a pigeons directory and run for every dart file in there.
You are also setup to only really support one generation, not multiple in one run. i would kind of like to be able to generate more than one, but that may be a sign that I should instead split things into separate plugins.
I will try to create feature requests, but I think this bug request could be used as a request to report an error instead of just blindly creating classes that replace the built in dart classes.
I think switching to templates might be a good place to start as it might make some of the other features easier in the long run.
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.
Activity
dalewking commentedon Jul 29, 2020
It isn't just bool. It will do the same thing for int or String.
dalewking commentedon Jul 29, 2020
And it isn't just the dart code, I see the same in generated JVM code as well and I assume in the Objective-C code as well.
So it looks like you only support passing classes as parameters. Which if that is the direction you want to go then it should generate an error not generate unusable code.
gaaclarke commentedon Jul 29, 2020
Hi @dalewking, yep currently parameters need to be void or a class. It definitely should give a good error for this.
There was talk of supporting single parameters at some point, too. That might be nice at some point too but is lower priority.
dalewking commentedon Jul 30, 2020
xster commentedon Jul 30, 2020
@dalewking I think they're all valid feature requests. Could you file individual bugs for those features?
Can we turn this bug into a feature request to support primitives in Pigeon?
gaaclarke commentedon Jul 30, 2020
@dalewking Thanks, most of those were on my radar.
The template idea is interesting. I hadn't considered that one, thanks. Like @xster said turning these into feature requests would be helpful.
dalewking commentedon Jul 30, 2020
Note I had found mustache4dart and i thought was not powerful enough, but according to the site it passes all the specification tests so I may have dismissed it too quickly. I since discovered a different mustache dart library that should also do the trick.
Another feature I would like is the ability to support not having to use command line parameters. You have the configuration method that can do most of it, but that only works if you specify input parameter. So I am thinking of perhaps you look for a pigeon_config.dart and include it and/or look for a pigeons directory and run for every dart file in there.
You are also setup to only really support one generation, not multiple in one run. i would kind of like to be able to generate more than one, but that may be a sign that I should instead split things into separate plugins.
dalewking commentedon Jul 30, 2020
I will try to create feature requests, but I think this bug request could be used as a request to report an error instead of just blindly creating classes that replace the built in dart classes.
I think switching to templates might be a good place to start as it might make some of the other features easier in the long run.
dalewking commentedon Jul 30, 2020
This might be a better and more powerful template engine than mustache: https://pub.dev/packages/liquid_engine
github-actions commentedon Aug 18, 2021
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.