Toggle Hide Password Icon color

Widgets & Design

In FlutterFlow's TextField, I want to configure the Toggle Hide Password Icon's color based on whether the password is visible or not. Here's the behavior I'm aiming for:

  1. When the password is hidden (default state), the icon should use the secondary color.

  2. When the password is visible, the icon should use the primary color.

Could you suggest a more robust way to achieve this functionality? Thank you!

What have you tried so far?

I couldn't find a setting that directly provides the current state of whether the password is visible or not.
Here's an attempt I made with a workaround:
Steps I Tried:

  1. Nested a TextField and a Container within a Stack.

  2. Set an onTap action on the container to toggle a Page State Variable called isPasswordVisible.

  3. Configured the Toggle Hide Password Icon's color:

    • isPasswordVisible == true β†’ Primary Color

    • isPasswordVisible == false β†’ Secondary Color

Issue:

When testing, the toggle icon and the container’s tap actions don’t fully synchronize. This often results in inconsistent behavior:

  • The password is visible, but the icon color is secondary (or vice versa).

  • This happens frequently, making it unreliable.

Did you check FlutterFlow's Documentation for this topic?
Yes
1