Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

change the color of unfocused text field icon #33183

Closed
Saifallak opened this issue May 22, 2019 · 9 comments
Closed

change the color of unfocused text field icon #33183

Saifallak opened this issue May 22, 2019 · 9 comments
Labels
a: text input Entering text in a text field or keyboard related problems c: new feature Nothing broken; request for a new capability f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. team-design Owned by Design Languages team

Comments

@Saifallak
Copy link

Saifallak commented May 22, 2019

Use case

Theming TextField unfouced icon color through themeData.

Proposal

i'm trying to use ThemeData to change the app colors at any moment, also it's easier to manage app when it's colors are contained in one single file like CSS does

what flutter can do? make the icon take the color of unselectedWidgetColor of themeData , i think it's the corrected color instead of hard Coded grey color

for more info about this request, you can check this stackoverflow as i though it's already implemented but it wasn't , they told me some workarounds , but i think it's easy to be implemented isn't it ?

@HansMuller HansMuller added d: stackoverflow Good question for Stack Overflow f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels May 22, 2019
@Saifallak
Copy link
Author

@HansMuller already asked on StackOverFlow but i think it should be implemented in Flutter in ThemeData like other widgets

@HansMuller HansMuller added c: new feature Nothing broken; request for a new capability and removed d: stackoverflow Good question for Stack Overflow labels May 22, 2019
@guidezpl guidezpl added the a: text input Entering text in a text field or keyboard related problems label Jun 19, 2020
@monisnap-julien
Copy link

Any update on this topic ? Still very hard to modify Textfield style...

@nxcco
Copy link

nxcco commented Feb 25, 2021

Any news on this?

@edex96
Copy link

edex96 commented May 7, 2021

Its hard coded
you can't use theme to override this color
but you can manage the icon's color state yourself
its not elegant but hey we developers are bombarded with so many obstacles everyday this should not upset us right.. right..
crying intensifies..

flutter/packages/flutter/lib/src/material/input_decorator.dart

Color _getDefaultIconColor(ThemeData themeData) {
    if (!decoration!.enabled && !isFocused)
      return themeData.disabledColor;

    switch (themeData.brightness) {
      case Brightness.dark:
        return Colors.white70;
      case Brightness.light:
        return Colors.black45;
    }
  }

@JamesMcIntosh
Copy link

JamesMcIntosh commented Jun 8, 2021

I can see two sensible expected behaviors:

  • Icon color is the same whether focused or not
  • Icon color is different when not focused

Material design doesn't have any clear specification about icon colors in text fields.
https://material.io/components/text-fields

If it's sensible to use the existing theme then hintColor or themeData.colorScheme.primary are good candidates (suggestions welcome).

My suggestion would be to replace:

final Color iconColor = isFocused ? activeColor : _getDefaultIconColor(themeData);

Color _getDefaultIconColor(ThemeData themeData) {
...
}

With:

final Color iconColor = _getIconColor(themeData);

Color _getIconColor(ThemeData themeData) {
  if (!decoration!.enabled && !isFocused) {
    return themeData.disabledColor;
  }

  if (isFocused) {
    return themeData.colorScheme.primary;
  }

  return themeData.hintColor;
}

The only problem with reusing the theme as suggested is when your desired colour is different from the hintColor, you will still not be able to specify it.

@kamrancr7
Copy link

Any update on this??

@flutter-triage-bot flutter-triage-bot bot added multiteam-retriage-candidate team-design Owned by Design Languages team triaged-design Triaged by Design Languages team labels Jul 8, 2023
@flutter-triage-bot flutter-triage-bot bot removed the triaged-design Triaged by Design Languages team label Oct 17, 2023
@flutter-triage-bot
Copy link

This issue is missing a priority label. Please set a priority label when adding the triaged-design label.

@HansMuller
Copy link
Contributor

This request has been resolved. See the last two examples on https://api.flutter.dev/flutter/material/InputDecoration-class.html

Copy link

This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of flutter doctor -v and a minimal reproduction of the issue.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 31, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
a: text input Entering text in a text field or keyboard related problems c: new feature Nothing broken; request for a new capability f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. team-design Owned by Design Languages team
Projects
None yet
Development

No branches or pull requests

8 participants