named arguments in dart code example
Example: dart positional arguments vs named arguments
void main(){
var catBob = Cat('Bob', 'Grey');
print(catBob.displayCat());
print(Dog(breed: 'Bulldog', name: 'Greg', color: 'Purple').displayDog());
}
class Cat{
String name;
String color;
Cat(this.name, this.color);
String displayCat() {
return 'my cat is ${name} and he is ${color}';
}
}
class Dog{
String name;
String breed;
String color;
Dog({this.name, this.breed, this.color});
String displayDog() {
return 'my ${breed} is ${name} and he is ${color}';
}
}