Answers for "object in dart"

3

object in dart

// Class declaration
class Car {
  
  String model;
  int year;
  var serialNumber;
  
  // Constructor
  Car(this.model, this.year, this.serialNumber);
  
}

// Follow me on Grepper for any future Dart Questions! Hope this Helps...
void main() {
  
  // Creating Object
  Car Honda = new Car('Civic', 2021, 'HZ326Y');
  
  print(Honda.year);
}

/* Syntax
class class_name {  
   <fields> 
   <getters/setters> 
   <constructors> 
   <functions> 
} */
Posted by: Guest on April-12-2021

Browse Popular Code Answers by Language