Skip to content

Instantly share code, notes, and snippets.

@muchirijane
Created September 25, 2019 10:25
Show Gist options
  • Save muchirijane/4608d61ea141c3dbcf19c0775b56f3a4 to your computer and use it in GitHub Desktop.
Save muchirijane/4608d61ea141c3dbcf19c0775b56f3a4 to your computer and use it in GitHub Desktop.
// All about class construtor and how to use this.
void main(){
Human jenny = Human(height: 15, weight: 3.4);
//jenny.talk('Mommy');
print(jenny.height);
print(jenny.weight);
Human james = Human(height: 20, weight: 4.2);
print(james.height);
print(james.weight);
// Human james = Human(20);
// print(james.height);
}
class Human {
double height;
double weight;
int age = 0;
Human({this.height, this.weight});
// or
// Human({double height, double weight}){
// this.height = height;
// this.weight = weight;
// }
void talk(String whatToSay){
print(whatToSay);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment