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}}{
{{/allowableValues}}
{{/vars}}
{{classname}}();
{{classname}}({
{{#vars}}
this.{{name}},
{{/vars}}
});
@override
String toString() {

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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