Skip to content

Instantly share code, notes, and snippets.

@faizan1947
Created July 16, 2022 04:06
Show Gist options
  • Save faizan1947/c9809327ffa27e4f17d4997b9216dfc5 to your computer and use it in GitHub Desktop.
Save faizan1947/c9809327ffa27e4f17d4997b9216dfc5 to your computer and use it in GitHub Desktop.
Inheritance-dart-lang

Inheritance-dart-lang

Created with <3 with dartpad.dev.

//[ Classes / Objects / Methds]
void main() {
//Creating Object [jaguar] from Car Class
var normalJaguar = Car();
//Accessing the method
normalJaguar.run('JAGUAR');
// Creating Object from ElectricCar Class
var tesla = ElectricCar();
//Accessing the method
tesla.run('TESLA');
}
//This is Class
class Car {
int seats = 4;
//Inside a class this is Method
void run(String carName) {
print('$carName is running');
}
}
//********* Dart Inheritance *********//
//Let's create Electric Car
// we dont want to creat again Car class because it have same functionalities
// Let's create inheritance Class using extends keyword
class ElectricCar extends Car {
//Now this ElectricCar Class have all properties of Car Class
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment