
Trying to add a flatbutton within textform field, below is code for current field implementation,
TextFormField(
textAlign: TextAlign.left,
obscureText: true,
cursorColor: Colors.white,
onChanged: (value) {
//Do something with the user input.
password = value;
},
style: TextStyle(color: Colors.white),
decoration: InputDecoration(
icon: Icon(Icons.help, color: Colors.white, ),
// contentPadding: EdgeInsets.fromLTRB(20, 20, 20, 20),
labelText: 'Enter your password',
labelStyle: TextStyle(color: Colors.white),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.white)),
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.white)),
),
),
Can someone assist on adding this as per the above screenshot.
Just add suffixIcon property inside InputDecoration implementation and pass FlatButton widget to it. Sample code below:
decoration: InputDecoration(
icon: Icon(Icons.help, color: Colors.black, ),
// contentPadding: EdgeInsets.fromLTRB(20, 20, 20, 20),
labelText: 'Enter your password',
labelStyle: TextStyle(color: Colors.black),
focusedBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.black)),
enabledBorder: UnderlineInputBorder(
borderSide: BorderSide(color: Colors.black)),
suffixIcon: FlatButton(
child: Text('Need Help?'),
onPressed: () {},
)
),

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With