Dart - generate constructor with named params (#6751)

* Dart - generate constructor with names params

* Test if constructor exists
This commit is contained in:
agilob 2020-06-27 08:11:36 +01:00 committed by GitHub
parent 1f277002a1
commit 1798fea3e7
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 57 additions and 12 deletions

View File

@ -6,7 +6,12 @@ class {{classname}} {
{{#min}} // range from {{min}} to {{max}}{{/min}}//{{^min}}enum {{name}}Enum { {{#values}} {{.}}, {{/values}} };{{/min}}{ {{#min}} // range from {{min}} to {{max}}{{/min}}//{{^min}}enum {{name}}Enum { {{#values}} {{.}}, {{/values}} };{{/min}}{
{{/allowableValues}} {{/allowableValues}}
{{/vars}} {{/vars}}
{{classname}}();
{{classname}}({
{{#vars}}
this.{{name}},
{{/vars}}
});
@override @override
String toString() { String toString() {

View File

@ -25,11 +25,12 @@ void main() {
..id = 124321 ..id = 124321
..name = 'Jose' ..name = 'Jose'
]; ];
return Pet() return Pet(
..id = id id : id,
..category = category category: category,
..tags = tags tags: tags,
..name = name name: name,
)
..status = status ..status = status
..photoUrls = ['https://petstore.com/sample/photo1.jpg']; ..photoUrls = ['https://petstore.com/sample/photo1.jpg'];
} }

View File

@ -7,7 +7,12 @@ class ApiResponse {
String type = null; String type = null;
String message = null; String message = null;
ApiResponse();
ApiResponse({
this.code,
this.type,
this.message,
});
@override @override
String toString() { String toString() {

View File

@ -5,7 +5,11 @@ class Category {
int id = null; int id = null;
String name = null; String name = null;
Category();
Category({
this.id,
this.name,
});
@override @override
String toString() { String toString() {

View File

@ -14,7 +14,15 @@ class Order {
//enum statusEnum { placed, approved, delivered, };{ //enum statusEnum { placed, approved, delivered, };{
bool complete = false; bool complete = false;
Order();
Order({
this.id,
this.petId,
this.quantity,
this.shipDate,
this.status,
this.complete,
});
@override @override
String toString() { String toString() {

View File

@ -14,7 +14,15 @@ class Pet {
/* pet status in the store */ /* pet status in the store */
String status = null; String status = null;
//enum statusEnum { available, pending, sold, };{ //enum statusEnum { available, pending, sold, };{
Pet();
Pet({
this.id,
this.category,
this.name,
this.photoUrls,
this.tags,
this.status,
});
@override @override
String toString() { String toString() {

View File

@ -5,7 +5,11 @@ class Tag {
int id = null; int id = null;
String name = null; String name = null;
Tag();
Tag({
this.id,
this.name,
});
@override @override
String toString() { String toString() {

View File

@ -17,7 +17,17 @@ class User {
String phone = null; String phone = null;
/* User Status */ /* User Status */
int userStatus = null; int userStatus = null;
User();
User({
this.id,
this.username,
this.firstName,
this.lastName,
this.email,
this.password,
this.phone,
this.userStatus,
});
@override @override
String toString() { String toString() {