2

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(),),
Programmer_3
  • 522
  • 5
  • 18

1 Answers1

0

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
  • 522
  • 5
  • 18
usman
  • 42
  • 8