Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I attach two Suffix Icon Button on TextFormField in Flutter?

Tags:

flutter

dart

I want this:

enter image description here

but I can't implement it.

I tried:

TextFormField(
        decoration: InputDecoration(
            labelText: Strings.AuthPage.PASSWORD,
            hasFloatingPlaceholder: true,
            suffixIcon: Row(
              children: <Widget>[
            IconButton(
            icon: Icon(Icons.clear),
            ),
                IconButton(
                  icon: Icon(snapshot.data ? Icons.visibility : Icons.visibility_off),
                  onPressed: _authBloc.switchObscureTextMode,
                ),
              ],
            ),
        ),
        controller: passwordController,
        obscureText: snapshot.data,
      ),

But the result was as follows:

enter image description here

Third screenshot.

So, How can I attach two Suffix Icon Button on TextFormField in Flutter?

like image 316
NeoMind Avatar asked Dec 05 '22 08:12

NeoMind


1 Answers

You have to use Property of Row Widget To achieve your desire output.

TextFormField(
            decoration: InputDecoration(
              labelText: Strings.AuthPage.PASSWORD,
              hasFloatingPlaceholder: true,
              suffixIcon: Row(
                mainAxisAlignment: MainAxisAlignment.spaceBetween, // added line
                mainAxisSize: MainAxisSize.min, // added line
                children: <Widget>[
                  IconButton(
                    icon: Icon(Icons.clear),
                  ),
                  IconButton(
                    icon: Icon(snapshot.data
                        ? Icons.visibility
                        : Icons.visibility_off),
                    onPressed: _authBloc.switchObscureTextMode,
                  ),
                ],
              ),
            ),
            controller: passwordController,
            obscureText: snapshot.data,
          ),
like image 174
Viren V Varasadiya Avatar answered Jun 09 '23 03:06

Viren V Varasadiya