这是indexloc提供的服务,不要输入任何密码
Skip to content

Add label widget parameter to InputDecoration #86810

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

Merged

Conversation

Renzo-Olivares
Copy link
Contributor

@Renzo-Olivares Renzo-Olivares commented Jul 21, 2021

Description

This change adds a new parameter to InputDecoration for a custom label widget. Previously only labelText was available for the label which takes in a string, and uses labelStyle and floatingLabelStyle for its styling. If someone wanted to style part of the label differently then they were not able to do so. Adding a label widget gives the developer this flexibility.

update

Related Issues

Fixes #55285

Tests

I added the following tests:

  • Tests to verify layout of label widget.
  • Tests to verify label widget inherits labelStyle and floatingLabelStyle when it is a text widget.

Pre-launch Checklist

  • I read the [Contributor Guide] and followed the process outlined there for submitting PRs.
  • I read the [Tree Hygiene] wiki page, which explains my responsibilities.
  • I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement].
  • I signed the [CLA].
  • I listed at least one issue that this PR fixes in the description above.
  • I updated/added relevant documentation (doc comments with ///).
  • I added new tests to check the change I am making or feature I am adding, or Hixie said the PR is test-exempt.
  • All existing and new tests are passing.

@flutter-dashboard flutter-dashboard bot added f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels. labels Jul 21, 2021
@google-cla google-cla bot added the cla: yes label Jul 21, 2021
@Renzo-Olivares Renzo-Olivares requested a review from justinmc July 21, 2021 20:36
@Renzo-Olivares Renzo-Olivares marked this pull request as ready for review July 21, 2021 21:00
Copy link
Contributor

@justinmc justinmc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some minor formatting problems here but otherwise looks good.

/// );
/// }
/// ```
/// {@end-tool}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good example!

@Renzo-Olivares Renzo-Olivares requested a review from justinmc July 22, 2021 00:30
@Renzo-Olivares Renzo-Olivares changed the title Required text input decoration Add label widget parameter to InputDecoration Jul 22, 2021
Copy link
Contributor

@justinmc justinmc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM 👍

Copy link
Contributor

@HansMuller HansMuller left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

/// Text that describes the input field.
/// Optional widget that describes the input field.
///
/// {@macro flutter.material.inputDecoration.labelText}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this macro be named "..inputDecoration.label"?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree with you. inputDecoration.label sounds more appropriate since this is shared between label and labelText.

@kausikMR
Copy link

kausikMR commented Aug 11, 2022

Thanks a lot!🙏 @Renzo-Olivares

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
f: material design flutter/packages/flutter/material repository. framework flutter/packages/flutter repository. See also f: labels.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add mandatory(*) for labelText in Input Decoration
5 participants