如何在TextFormField中添加额外的标签?

问题描述 投票:0回答:1

有没有办法在TextFormField中定位“忘记密码”标签?

在示例图片上放忘了密码?在输入内部

new TextFormField(
                    decoration: InputDecoration(labelText: 'Password',
                      labelStyle: TextStyle(
                        color: Colors.black87,
                        fontSize: 17,
                        fontFamily: 'AvenirLight'
                      ),
                      focusedBorder: UnderlineInputBorder(      
                        borderSide: BorderSide(color: Colors.purple),   
                      ),
                      enabledBorder: new UnderlineInputBorder(
                        borderSide: BorderSide(color: Colors.grey, 
                          width: 1.0)
                      ),
                    ),
                    style: TextStyle(
                      color: Colors.black87,
                      fontSize: 17,
                      fontFamily: 'AvenirLight'
                    ),
                    controller: _passwordController,
                    obscureText: true,
                  ),
flutter flutter-layout
1个回答
4
投票

使用 - Suffix:InputDecoration:属性

TextFormField(
            decoration: InputDecoration(
              suffix: GestureDetector(
                onTap: () {
                  print('tapped');
                },
                child: Text(
                  'Forgot Password?',
                  style: TextStyle(
                      color: Colors.blue, fontWeight: FontWeight.bold),
                ),
              ),
              labelText: 'Password',
              labelStyle: TextStyle(
                  color: Colors.black87,
                  fontSize: 17,
                  fontFamily: 'AvenirLight'),
              focusedBorder: UnderlineInputBorder(
                borderSide: BorderSide(color: Colors.purple),
              ),
              enabledBorder: new UnderlineInputBorder(
                  borderSide: BorderSide(color: Colors.grey, width: 1.0)),
            ),
            style: TextStyle(
                color: Colors.black87, fontSize: 17, fontFamily: 'AvenirLight'),
            //  controller: _passwordController,
            obscureText: true,
          ),

<code>enter image description here</code>

© www.soinside.com 2019 - 2024. All rights reserved.