Expanded myui() {
return Expanded(
child: TextButton(
onPressed: () {
audio(1);
},
style: TextButton.styleFrom(backgroundColor: Colors.red),
child: const Text(
"",
),
),
);
}
how pass parameters for this " TextButton.styleFrom(backgroundColor: Colors.red) " with myui function?
>Solution :
Update it as:
Expanded myui(Color bgColor) {
return Expanded(
child: TextButton(
onPressed: () {
audio(1);
},
style: TextButton.styleFrom(backgroundColor: bgColor),
child: const Text(""),
),
);
}
User as:
myui(Colors.green);