Here CuButton
showing error. I also created same widget but not showing errors but in this case it shows error
` Widget CuBUtton({
String name = "button",
Color color = Colors.blueGrey,
double H = 10,
double W = 10,
required Function function,
required TextStyle Labelstyl}) {
try {
return
InkWell(onTap: () {
function();
},
child: Container(color: color,
height: H, width: W,
child: Center(child:
Text(name,style: Labelstyl,)),),
);
} catch (e) {
print("Error on Button $e");
}
}`
CodePudding user response:
Remove the required keyword
from the function
:
Widget CuButton({
String name = "button",
Color color = Colors.blueGrey,
double H = 10,
double W = 10,
Function function,
TextStyle Labelstyl}) {
try {
return InkWell(
onTap: () {
function();
},
child: Container(
color: color,
height: H,
width: W,
child: Center(
child: Text(name, style: Labelstyl),
),
),
);
} catch (e) {
print("Error on Button $e");
}
}