美文网首页
不常用的细节2023-12-26

不常用的细节2023-12-26

作者: iOS打怪升级 | 来源:发表于2023-12-25 18:10 被阅读0次
  1. 消除TextButton.icon的四周边距:style
style: ButtonStyle(padding: MaterialStateProperty.all(EdgeInsets.zero)),
                      
  1. 设置TextButton按钮的圆角
 TextButton(
            style: ButtonStyle(
              backgroundColor: MaterialStateProperty.all(Colors.red),
              shape: MaterialStateProperty.all<RoundedRectangleBorder>(
                RoundedRectangleBorder(
                  borderRadius: BorderRadius.circular(10.0),
                ),
              ),
            ),
          ),

  1. 实现文本+图片的按钮: 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;
                                });
                              },
                            )

相关文章

网友评论

      本文标题:不常用的细节2023-12-26

      本文链接:https://www.haomeiwen.com/subject/qjlkndtx.html