Dart Plugin - copyWith method for Dart Classes

There should be an option to generate a copyWith method for a Dart class. I think this is a frequently used pattern in the community. It widely used in the Flutter framework itself.

Example:

class Dog {
final String name;
final String breed;
final int birthYear;

const Dog({
this.name,
this.breed,
this.birthYear,
});

Dog copyWith({
String name,
String breed,
int birthYear,
}) {
return Dog(
name: name ?? name,
breed: breed ?? breed,
birthYear: birthYear ?? birthYear,
);
}
}
1 comment
Comment actions Permalink

please feel free to file a request for this feature to youtrack, https://youtrack.jetbrains.com/issues/WEB

0

Please sign in to leave a comment.