代码
import 'package:flutter/material.dart';
class InputBoxContainer extends StatefulWidget {
InputBoxContainer({Key key, this.onChange, this.icon}) : super(key: key);
final onChange;
final IconData icon;
@override
State<StatefulWidget> createState() {
return InputBoxContainerBuilder();
}
}
class InputBoxContainerBuilder extends State<InputBoxContainer> {
Widget build(BuildContext context) {
return Container(
padding: EdgeInsets.only(left: 10.0, right: 10.0, top: 2.0, bottom: 2.0),
margin: EdgeInsets.only(bottom: 30.0),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(100.0),
border: Border.all(
width: 1.0,
style: BorderStyle.solid,
color: Color.fromRGBO(0, 0, 0, 0.1))),
child: TextField(
onChanged: widget.onChange,
decoration: InputDecoration(
border: InputBorder.none,
icon: widget.icon != null ? Icon(widget.icon) : null),
),
);
}
}
预览