如何设计像这样的颤抖的Textfield边框

时间:2020-10-08 07:37:50

标签: flutter dart flutter-layout

我想像这样设计Flutter文本字段,任何人都可以帮助我。

1

Image Reference

3 个答案:

答案 0 :(得分:1)

将“文本字段”包装在“主题”小部件和“材质”小部件中

增加阴影效果的高度

         Theme(
          data: ThemeData(
            primaryColor: Colors.black,
            primaryColorDark: Colors.black,
          ),
          child: Material(
            borderRadius: const BorderRadius.all(Radius.circular(18)),
            elevation: 5,
            shadowColor: Color(0XFF000000),
            child: TextField(
              decoration: InputDecoration(
                border: OutlineInputBorder(
                  borderRadius: const BorderRadius.all(Radius.circular(18)),
                ),
              ),
            ),
          ),
        ),

它看起来像这样

enter image description here

答案 1 :(得分:0)

您可以使用容器将其扭曲并设置

decoration: Boxdecoration(
border: ...
borderRadius: ...
boxShadow: ...
),

答案 2 :(得分:0)

您可以将InputDecoration.collapsed用于TextField,并用这样的容器包装它:

Container(
        height: 42,
        child: Center(
          child: Padding(
            padding: const EdgeInsets.fromLTRB(16, 8, 16, 8),
            child: TextField(
              decoration: InputDecoration.collapsed(hintText: "Your Hint", hintStyle: TextStyle(color: Colors.black,fontWeight: FontWeight.bold)),
              textAlign: TextAlign.right,
            ),
          ),
        ),
        decoration: BoxDecoration(
          color: Colors.white,
          borderRadius: BorderRadius.all(Radius.circular(18)),
          boxShadow: [
            BoxShadow(
              color: Colors.black.withOpacity(0.75),
              spreadRadius: 3,
              blurRadius: 0,
              offset: Offset(2, 2), // changes position of shadow
            ),
          ],
        ),
      )

它看起来像这样:

enter image description here