-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Open
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projectp: pigeonrelated to pigeon messaging codegen toolrelated to pigeon messaging codegen toolpackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.team-ecosystemOwned by Ecosystem teamOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem teamTriaged by Ecosystem team
Description
Use case
Currently, Pigeon generates constructors with named parameters for all fields, even if a different constructor is provided. For example:
class AndroidColor {
AndroidColor.fromARGB(this.a, this.r, this.g, this.b);
final int a;
final int r;
final int g;
final int b;
}generates
/// A color on Android.
class AndroidColor {
AndroidColor({
required this.a,
required this.r,
required this.g,
required this.b,
});
int a;
int r;
int g;
int b;
// ...
}Even though it would not have been an error to include the original .fromARGB constructor, Pigeon opted not to do so. This makes porting existing code to Pigeon difficult, and if the class is part of the public API, it's impossible to feed it through Pigeon without forcing a breaking change.
Proposal
When generating constructors, Pigeon should first check if the unnamed constructor already exists, and if so, copy it as-is instead of overwriting it. When other constructors exist, Pigeon should copy those, even if it decides to generate its own unnamed constructor.
Metadata
Metadata
Assignees
Labels
P3Issues that are less important to the Flutter projectIssues that are less important to the Flutter projectp: pigeonrelated to pigeon messaging codegen toolrelated to pigeon messaging codegen toolpackageflutter/packages repository. See also p: labels.flutter/packages repository. See also p: labels.team-ecosystemOwned by Ecosystem teamOwned by Ecosystem teamtriaged-ecosystemTriaged by Ecosystem teamTriaged by Ecosystem team