且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 Flutter 中向 TextFormField 添加阴影

更新时间:2023-01-06 10:41:52

您可以使用 Material 小部件包装您的 TextFormField 并编辑其属性,例如 elevationshadowColor.

You can Wrap your TextFormField with a Material widget and edit its properties such as elevation and shadowColor.

例子:

Material(
              elevation: 20.0,
              shadowColor: Colors.blue,
                          child: TextFormField(
                obscureText: true,
                autofocus: false,
                decoration: InputDecoration(
                    icon: new Icon(Icons.lock, color: Color(0xff224597)),
                    hintText: 'Password',
                    fillColor: Colors.white,
                    filled: true,
                    contentPadding: EdgeInsets.fromLTRB(20.0, 10.0, 20.0, 10.0),
                    enabledBorder: OutlineInputBorder(borderRadius:BorderRadius.circular(5.0),
                    borderSide: BorderSide(color: Colors.white, width: 3.0))
                ),
              ),
            )  

您将获得类似于下图的内容.

You will Get something similar to the image below.