- 消除TextButton.icon的四周边距:style
style: ButtonStyle(padding: MaterialStateProperty.all(EdgeInsets.zero)),
- 设置TextButton按钮的圆角
TextButton(
style: ButtonStyle(
backgroundColor: MaterialStateProperty.all(Colors.red),
shape: MaterialStateProperty.all<RoundedRectangleBorder>(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(10.0),
),
),
),
),
- 实现文本+图片的按钮: TextButton.icon 的icon +label
TextButton.icon(
style: ButtonStyle(padding: MaterialStateProperty.all(EdgeInsets.zero)),
onPressed: () {
if (onTap != null) {
onTap!(model, 0);
}
},
icon: Image.asset(
model.status == 1
? 'assets/HQOrderManager/addressSelected.png'
: 'assets/HQOrderManager/addressUnselected.png',
width: 12,
),
label: const Text(
'设为默认',
style:
TextStyle(color: Color(0xFFA7A7A7), fontSize: 12),
),
)
3 输入框相关:标题+ 输入文本
TextFormField(
enabled:false,
readOnly: true,
initialValue: _region,
// autofocus: ,
style: const TextStyle(color: Color(0xff1D1E18)),
decoration: InputDecoration(
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(
color: Colors.grey.withOpacity(0.2)),
),
hintText: '请选择所在地区',
hintStyle:
const TextStyle(color: Color(0xff9C9C9C)),
// prefixIcon: GestureDetector(
// onTap: () {
// _showAddressPicker();
// },
// child: Container(
// width: 90,
// alignment: Alignment.center,
// child: const Text(
// '所在地区:',
// style: TextStyle(
// color: Color(0xff010B16), fontSize: 16),
// ),
// ),
// ),
focusedBorder: const UnderlineInputBorder(
borderSide: BorderSide(color: Colors.blue))),
validator: (value) {
if (value.isNull() || value!.isEmpty) {
return '请选择所在区域';
}
return null;
},
onChanged: (value) {
setState(() {
_name = value;
});
},
)
网友评论