【问题标题】:Flutter - How to get dashed InputDecoration border in TextFormField?Flutter - 如何在 TextFormField 中获得虚线 InputDecoration 边框?
【发布时间】:2020-05-27 16:46:06
【问题描述】:

预期设计:Image

这就是当前 InputDecoration 的样子。我想给出一个带有可调节间隙值的虚线圆形边框。

 InputDecoration(
            contentPadding: EdgeInsets.symmetric(vertical: 0, horizontal: 15.0),
            filled: true,
            fillColor: Colors.white,
            focusedBorder: OutlineInputBorder(
              borderSide: BorderSide(color: Kolors.accent, width: 5.0,),
              borderRadius: BorderRadius.all(Radius.circular(40)),
            ),)

【问题讨论】:

标签: android flutter dart flutter-layout


【解决方案1】:

我认为InputBorder 目前还没有用于TextFormField 的虚线InputBorder 功能。但是,我找到了使用此包dotted_border 的解决方案。

解决办法:

                  DottedBorder(
                      color: _isFocused ? Kolors.accent : Kolors.stroke,
                      strokeWidth: 1.5,
                      dashPattern: [7, 4],
                      borderType: BorderType.RRect,
                      radius: Radius.circular(40),
                      child: TextFormField(
                        controller: _promoController,
                        cursorColor: Kolors.textGrey,
                        style: TextStyle(
                            color: Kolors.textBlack,
                            fontSize: 14,
                            fontWeight: FontWeight.w400,
                            fontStyle: FontStyle.normal),
                        decoration: InputDecoration(
                            contentPadding:
                                EdgeInsets.symmetric(horizontal: 15),
                            border: OutlineInputBorder(
                              borderSide: BorderSide.none,
                              borderRadius: BorderRadius.circular(0),
                            ),
                            hintText: "Type your promocode",
                            hintStyle: TextStyle(
                                color: Kolors.textHint,
                                fontSize: 14)),
                      ),
                    ),

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2021-03-03
    • 2012-11-15
    • 2021-08-25
    • 2021-08-05
    • 2021-11-15
    • 2011-09-05
    • 2019-09-05
    相关资源
    最近更新 更多