我尝试在构造函数中创建一些带有一些参数的自定义小部件。这个小部件有一些可选和必需的参数。
如何Function
在我的Widget
.
class TextInputWithIcon extends StatefulWidget {
final String iconPath;
final String placeHolder;
final Function(bool) onFocusChange;
const TextInputWithIcon(
{Key key,
@required this.iconPath,
this.placeHolder = "",
this.onFocusChange})
: super(key: key);
@override
_TextInputWithIconState createState() => _TextInputWithIconState();
}
class _TextInputWithIconState extends State<TextInputWithIcon> {
@override
Widget build(BuildContext context) {
return MY_WIDGET;
}
}