【问题标题】:Attach two suffix icon with background on textfield in flutter?在颤动的文本字段上附加两个带背景的后缀图标?
【发布时间】:2021-12-01 08:53:10
【问题描述】:

我希望结果是这样的,

但到目前为止我所取得的成就是

“发件人”标签不是问题,但大纲才是问题。

这是我的文本字段的代码。

            TextField(
              enabled: false,
              decoration: InputDecoration(
                disabledBorder: OutlineInputBorder(
                  borderSide:
                      BorderSide(color: colorx.Colors.black, width: 0.7),
                ),
                hintText: 'YYYY-MM-DD',
                hintStyle: TextStyle(color: Colors.black12),
                suffixIcon: Container(

                  height: 58,
                  width: 80,
                  decoration:
                      BoxDecoration(color: colorx.Colors.paleGreyTwo,),


                  child: Row(
                    mainAxisAlignment: MainAxisAlignment.spaceEvenly,
                    // added line
                    mainAxisSize: MainAxisSize.min,
                    // added line

                    children: [
                      Image.asset(
                        "graphics/calender.png",
                      ),
                      Image.asset(
                        "graphics/refresh_date.png",
                      ),
                    ],
                  ),
                ),
              ),
              style: TextStyle(color: Colors.black),
            ),

【问题讨论】:

    标签: flutter flutter-layout flutter-dependencies


    【解决方案1】:

    试试下面的代码希望它对你有帮助。只需将我的图标更改为您的图片即可

       TextField(
                    enabled: false,
                    decoration: InputDecoration(
                      disabledBorder: OutlineInputBorder(
                        borderSide: BorderSide(color: Colors.black, width: 0.7,),
                      ),
                      hintText: 'YYYY-MM-DD',
                      hintStyle: TextStyle(color: Colors.black12,),
                      suffixIcon: Container(
                        margin: EdgeInsets.all(1),
                        height: 58,
                        width: 100,
                        decoration: BoxDecoration(
                            color: Colors.grey,
                            border: Border(
                              left: BorderSide(
                                 color: Colors.black,
                                width: 1.0,
                              ),
                            ),),
                        child: IntrinsicHeight(
                          child: Row(
                            mainAxisAlignment:
                                MainAxisAlignment.spaceEvenly,  
                            mainAxisSize: MainAxisSize.min,  
                            children: <Widget>[
                              Icon(Icons.date_range,),
                              VerticalDivider(
                                color: Colors.black,
                                thickness: 1,
                              ),
                              Icon(Icons.close,),
                            ],
                          ),
                        ),
                      ),
                    ),
                    style: TextStyle(
                      color: Colors.black,
                    ),
                  ),
    

    您的结果屏幕->

    【讨论】:

    • 谢谢,但图标仍然不在中心。
    • @KanwarpreetSingh 刚刚设置为填充图标
    猜你喜欢
    • 1970-01-01
    • 2010-11-16
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-08-08
    • 2017-05-10
    • 2021-03-04
    • 2019-09-07
    相关资源
    最近更新 更多