Why Flutter favour composition over inheritence?
Flutter prefer composition over inheritance because it is easy to manage since it represent "" has a " relationship. Consider this
Class person{
String name;
Address add;
}
In above scenario , it is better practice to make separate class for address because it contain multiple information like house no,city,country postal code etc.if you place all the information inside person class this should work but not in a better way.
Programmer_3
My name is usama Sarfraz.I am a student and doing BS in software Engineering.Currently I am learning flutter to make Professional android apps.
Updated on December 22, 2022Comments
-
Programmer_3 about 13 hours
Some places on internet, i read RaisedButton uses composition like text widget that contain other properties to set Text?
My question is what does it mean?What happens if use inheritence instead of composition? Here is code:RaisedButton( child: Text("Decrement Counter"), onPressed: () => _decrementCounter(),),