Issue
I have a form textfield and i want to put textbutton as a suffix for i forgot password. But when i try add i cant see anything.
My Code:
TextFormField(
decoration: InputDecoration(
suffix:TextButton(child: Text("Şifremi Unuttum?"),onPressed: (){})
),
floatingLabelStyle: TextStyle(
color: isFocused
? Color.fromARGB(255, 141, 56, 211)
: Color.fromARGB(255, 91, 103, 125),
fontWeight: FontWeight.w500,
fontSize: 14),
),
),
When i check suffix wants a widget. So i gave it but its not showing what is the problem in here ? Thanks for helps!!
Solution
Everything works for me with your source code. The TextButton is displayed correctly. I will attach the code below, as well as a screenshot, where I added the missing label, because you use styling for it and a condition if you forgot the password, then display a text button in the suffix:
class _MyHomePageState extends State<MyHomePage> {
static bool isFocused = true;
static bool isForgotPassword = true;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: const Text("App bar"),
),
body: TextFormField(
initialValue: "My Text",
decoration: InputDecoration(
suffix: isForgotPassword ? TextButton(
child: const Text("Şifremi Unuttum?"), onPressed: () {}) : null,
label: const Text(
"Floating Label",
style: TextStyle(fontSize: 25),
),
floatingLabelStyle: TextStyle(
color: isFocused
? const Color.fromARGB(255, 141, 56, 211)
: const Color.fromARGB(255, 91, 103, 125),
fontWeight: FontWeight.w500,
fontSize: 14),
),
));
}
}
Screenshot of app screen with 2 false booleans
Answered By – Legend5366
Answer Checked By – David Marino (FlutterFixes Volunteer)