Skip to content

CupertinoTextField unable to override the default placeholder color. #24175

Closed

Description

@ffimnsr

I'm having problems on overriding the default color for placeholder in CupertinoTextField. As I'm trying to set it white it always turns to gray. I've inspected the flutter source base and found this:

if (widget.placeholder != null && text.text.isEmpty) {
stackChildren.add(
Padding(
padding: widget.padding,
child: Text(
widget.placeholder,
maxLines: 1,
overflow: TextOverflow.ellipsis,
style: widget.style.merge(
const TextStyle(
color: _kInactiveTextColor,
fontWeight: FontWeight.w300,
),
),
),
),
);
}

Is there any other way around this?
Here is my flutter installation details:

Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel beta, v0.10.2, on Linux, locale en_US.UTF-8)
[✓] Android toolchain - develop for Android devices (Android SDK 28.0.2)
[✓] Android Studio (version 3.1)
    ✗ Flutter plugin not installed; this adds Flutter specific functionality.
[✓] Connected device (1 available)

• No issues found!

Activity

  1. added
    frameworkflutter/packages/flutter repository. See also f: labels.
    p: cupertino_uicupertino_ui package in flutter/packages
    on Nov 11, 2018
  2. added this to the milestone on Nov 11, 2018
  3. xster commented on Nov 12, 2018

    @xster
    Member

    Indeed it is static since it's not customizable on iOS either. https://developer.apple.com/documentation/uikit/uitextfield/1619621-placeholder?language=objc

    Do you have a mock-up of the effects you're trying to achieve?

  4. ffimnsr commented on Nov 13, 2018

    @ffimnsr
    Author

    Indeed @xster, but what do I override it? The default placeholder is just text in regards to that, developers given an option to customize it using attributedPlaceholder to set UIColor.
    https://developer.apple.com/documentation/uikit/uitextfield/1619610-attributedplaceholder?language=objc

    Well, what I'm trying to achieve is set the placeholder color similar to the text color of the UITextField.

                          child: CupertinoTextField(
                            style: TextStyle(color: CupertinoColors.white),
                            placeholder: "Email",
                            decoration: BoxDecoration(
                              border: Border.all(
                                width: 0.0,
                                color: Color(0x00FFFFFF),
                              ),
                            ),
                            controller: _emailController,
                            onChanged: (String value) {
                              _data.email = value.trim();
                            },
                          ),
    
  5. xster commented on Nov 13, 2018

    @xster
    Member

    Ah, sensible to add a placeholderStyle to CupertinoTextField in this case. Feel free to send us a PR as well :)

  6. ffimnsr commented on Nov 21, 2018

    @ffimnsr
    Author

    Hi @xster, I've submitted a minor update for the placeholder customization.

  7. github-actions commented on Aug 14, 2021

    @github-actions

    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.

  8. locked as resolved and limited conversation to collaborators on Aug 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    a: fidelityMatching the OEM platforms betterframeworkflutter/packages/flutter repository. See also f: labels.p: cupertino_uicupertino_ui package in flutter/packages

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions