Expanded constroiBotoes ({String? caracterDaTecla, Color corTecla = Colors.white, Function? onPress}){
return Expanded(
child: ElevatedButton(
child: Text(caracterDaTecla!),
style: ElevatedButton.styleFrom(
textStyle: TextStyle(
fontSize: 28,
color: corTecla
),
),
onPressed : onPress,
),
);
}
lib/主要。dart:170:21:错误:参数类型为Function?'不能赋值给参数类型'void Function()?'.
- 'Function'来自'dart:core'。onPressed: onPress,
使用ElevatedButton
的onPressed
参数所使用的VoidCallback
类型
Expanded constroiBotoes({
String? caracterDaTecla,
Color corTecla = Colors.white,
VoidCallback? onPressed, // <---- HERE
}){
return Expanded(
child: ElevatedButton(
child: Text(caracterDaTecla!),
style: ElevatedButton.styleFrom(
textStyle: TextStyle(
fontSize: 28,
color: corTecla
),
),
onPressed: onPressed,
),
);
}