class constructors dart code example

Example 1: dart ?? operator

int val1;
final int val2 = 20;

console.log(val1 ?? val2); //result => 20 because val1 is null

----------------------------------

final int val1 = 30;
final int val2 = 20;

console.log(val1 ?? val2); //result => 30 because val1 is not null

Example 2: constructoers in flutter

Customer(this.name, this.age, this.location);

Customer.withoutLocation(this.name, this.age);

Customer.empty() {
  name = "";gd
  location = "";
}
cfgdfgdfgdfggdfgdfdfgdfgdggdfgdfgdf

Tags:

Misc Example