错误未失效颤振函数帮助我


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,

使用ElevatedButtononPressed参数所使用的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,
),
);
}

最新更新