Skip to content

Commit

Permalink
Dart - generate constructor with named params (#6751)
Browse files Browse the repository at this point in the history
* Dart - generate constructor with names params

* Test if constructor exists
  • Loading branch information
agilob authored Jun 27, 2020
1 parent 1f27700 commit 1798fea
Show file tree
Hide file tree
Showing 8 changed files with 57 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
11 changes: 6 additions & 5 deletions samples/client/petstore/dart2/petstore/test/pet_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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'];
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,12 @@ class ApiResponse {
String type = null;

String message = null;
ApiResponse();

ApiResponse({
this.code,
this.type,
this.message,
});

@override
String toString() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ class Category {
int id = null;

String name = null;
Category();

Category({
this.id,
this.name,
});

@override
String toString() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,11 @@ class Tag {
int id = null;

String name = null;
Tag();

Tag({
this.id,
this.name,
});

@override
String toString() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 1798fea

Please sign in to comment.