onPressed出错 尝试传递onPressed函数但是出现了错误。
错误 - 参数类型'Function'不能被赋值给参数类型'void Function()?'.
class CircleButton extends StatelessWidget {
CircleButton({required this.icon, required this.onPressed});
final IconData icon;
final Function onPressed; [![Error][1]][1]//Here
@override
Widget build(BuildContext context) {
return ElevatedButton(
child: Icon(icon),
onPressed: onPressed,
style: ElevatedButton.styleFrom(
elevation: 6.0,
primary: Color(0xFF4C4F5E),
shape: CircleBorder(),
padding: EdgeInsets.all(15),
),);
}}