Skip to content

Instantly share code, notes, and snippets.

@angwandi
Last active February 8, 2020 12:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save angwandi/fa42a935747488f4e77cf682bf30fbf7 to your computer and use it in GitHub Desktop.
Save angwandi/fa42a935747488f4e77cf682bf30fbf7 to your computer and use it in GitHub Desktop.
class and object in Dart
void main(){
//dema is the actual objet
Human dema = Human(height:15,age:12);
print(dema.height);
dema.talk('Why is the sky blue??');
Human innocent = Human(height: 1.6,age:30);
print(innocent.height);
}
//blueprint of all humans
class Human{
//class feilds or properties : variables associated to the class
double height;
int age;
//class constructor : initialize the values of class properties
Human({this.height,this.age});
//class methode : method associated to the class
void talk(String whatToSay){
print(whatToSay);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment