Created with <3 with dartpad.dev.
Created
July 16, 2022 04:06
-
-
Save faizan1947/c9809327ffa27e4f17d4997b9216dfc5 to your computer and use it in GitHub Desktop.
Inheritance-dart-lang
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//[ 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