INNER CODE UNIT · Dart
tesla
antz22/ultimate-guide-to-flutter · code/dart_examples.dart:104
Car tesla = Car(); // class is instantiated with parentheses, ()
// populating each of the attributes we defined in the above class
tesla.name = 'Model S';
tesla.price = 50000;
tesla.isMadeByElonMusk = true;
}
// define a class named car
class Car {
// define a constructor that takes in a String name, int price and bool isMadeByElonMusk
Car(String name, int price, bool isMadeByElonMusk) {
// set all the object's attributes equal to the inputs passed in
this.name = name;
this.price = price;
this.isMadeByElonMusk = isMadeByElonMusk;
}