Skip to content

Instantly share code, notes, and snippets.

@simrandotdev
Created March 15, 2019 17:07
Show Gist options
  • Save simrandotdev/491fcf6c20cbe32871652423925f97fc to your computer and use it in GitHub Desktop.
Save simrandotdev/491fcf6c20cbe32871652423925f97fc to your computer and use it in GitHub Desktop.
Functions in Dart
void main() {
String name = 'Simran';
int age = 28;
final double height = 1.84; // You cannot change this variable as it is declared final
var occupation = "Mobile App Developer";
dynamic weight = 90;
describe(name, age, height, occupation, weight);
describe("Jassi", 29, 1.9, "Software Engineer");
print(printMe(name:"Simran", age:28));
print(printMe(name:"Jassi", age:28));
}
void describe(String name, int age, double height, String occupation, [dynamic weight = 100]) {
print("Hello, I am $name.");
print("My name has ${name.length} letters.");
print("I am $age years old.");
print("My height is $height meters tall.");
print("I work as an Independent '$occupation'.");
print("In 2019 I weighed $weight Kgs");
weight = "75";
print("But I wanna weight $weight Kgs\n\n");
}
String printMe({String name, int age}) {
return "My name is $name and I am $age years old.";
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment