所以在我的設計中,我的文本欄位是這樣的:

我怎樣才能在 Flutter 中做到這一點?
uj5u.com熱心網友回復:
我不知道正確的大小和顏色,因此請根據您的設計更改它們,如果您希望可以使用圖示資產而不是 Icons 類。
@override
Widget build(BuildContext context) {
double width = MediaQuery.of(context).size.width;
double height = MediaQuery.of(context).size.height;
return Scaffold(
backgroundColor: Colors.pink.shade50,
body: Center(
child: Container(
width: width * 0.8,
height: height * 0.07,
padding: EdgeInsets.all(width * 0.03),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(6),
color: Colors.white,
border: Border.all(color: Colors.grey)),
child: Center(
child: Row(
children: <Widget>[
const Icon(
Icons.email,
color: Colors.grey,
),
SizedBox(
width: width * 0.04,
),
const Expanded(
child: TextField(
decoration: InputDecoration.collapsed(
hintText: '[email protected]',
hintStyle: TextStyle(color: Colors.grey)),
),
),
],
),
),
),
),
);
}

uj5u.com熱心網友回復:
如果您的意思是無邊框文本欄位,那么您可以輕松更改與背景顏色相同的邊框顏色,
否則請遵循此代碼
TextFormField(
cursorColor: Colors.black,
keyboardType: inputType,
decoration: new InputDecoration(
border: InputBorder.none,
focusedBorder: InputBorder.none,
enabledBorder: InputBorder.none,
errorBorder: InputBorder.none,
disabledBorder: InputBorder.none,
contentPadding:
EdgeInsets.only(left: 15, bottom: 11, top: 11, right: 15),
hintText: "[email protected]"),
)
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/401085.html
