我创建了一个带有阴影的自定义圆形TextField
小部件。我唯一无法设置的是小部件的高度。我遵循了这个SO答案来设置高度,但不幸的是,它没有正确设置子项的高度(它会缩小输入,但不会将阴影放置在容器中):
我的小部件:
class Input extends StatelessWidget {
final String hintText;
Input(this.hintText);
@override
Widget build(BuildContext context) {
return Container(
height: 50,
child: SizedBox(
height: double.infinity,
child: Container(
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(30),
boxShadow: [
BoxShadow(
color: Color.fromRGBO(0, 0, 0, 0.05),
blurRadius: 15,
offset: Offset(0, 10),
spreadRadius: 10)
]),
child: TextField(
decoration: InputDecoration(
enabledBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.white, width: 1),
borderRadius: BorderRadius.circular(30)),
border: OutlineInputBorder(
borderSide: BorderSide(color: Colors.white, width: 1),
borderRadius: BorderRadius.circular(30)),
filled: true,
hintStyle: TextStyle(color: Color.fromRGBO(184, 184, 184, 1)),
contentPadding: EdgeInsets.all(20),
hintText: hintText,
focusedBorder: OutlineInputBorder(
borderSide: BorderSide(color: Colors.white, width: 1),
borderRadius: BorderRadius.circular(30)),
fillColor: Colors.white),
))),
);
}
}