I am new in Flutter.
Here is my code,
For ElevatedButton,
ElevatedButton(
onPressed: () {
// Add your onPressed code here!
},
child: Text("Login"),
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all<Color>(
AppColors.SecondaryColor),
foregroundColor: MaterialStateProperty.all<Color>(
AppColors.PrimaryColor))),
For OutlinedButton,
OutlinedButton(
onPressed: () {
// Add your onPressed code here!
},
child: Text("Register Now"),
style: OutlinedButton.styleFrom(
side: BorderSide(width: 2, color: AppColors.SecondaryColor),
))
My question is why I must use styleFrom for OutlinedButton instead of ButtonStyle? if substitute OutlinedButton.styleFrom with ButtonStyle, it gives error. Why?
I am very confuse with the usage of ButtonStyle and styleFrom. Because some of the example on the internet use ButtonStyle while some use styleFrom.
