Repository navigation
Conversation
TextField.decoration's dartdoc did not mention that the decoration passed here is combined with the ambient InputDecorationTheme via InputDecoration.applyDefaults, rather than replacing it. That makes it non-obvious why, for example, a theme-provided border survives an InputDecoration that simply omits one. Document the merge and point at the explicit opt-out. Addresses the documentation half of flutter#159629
|
This pull request contains changes to Material or Cupertino, which are currently frozen in this repository. Changes should be made in Please refer to #188444 for instructions. |
There was a problem hiding this comment.
Code Review
This pull request updates the documentation for the decoration property of TextField to clarify how it merges with the ambient InputDecorationTheme. Feedback was provided to correct an inaccurate reference to a non-existent InputDecorationTheme.of method, suggesting instead to refer directly to the ambient ThemeData.inputDecorationTheme.
| /// This decoration does not replace the ambient [InputDecorationTheme], it is | ||
| /// merged with it by [InputDecoration.applyDefaults]. Only the properties | ||
| /// that are left null here take their value from [InputDecorationTheme.of], | ||
| /// which in turn defaults to [ThemeData.inputDecorationTheme]. So, for | ||
| /// example, when the theme specifies a border, passing an [InputDecoration] | ||
| /// that leaves [InputDecoration.border] null does not remove that border; | ||
| /// pass `border: InputBorder.none` to opt out of it explicitly. |
There was a problem hiding this comment.
There is no InputDecorationTheme.of method in Flutter. The ambient input decoration theme is retrieved via Theme.of(context).inputDecorationTheme. It is clearer and more accurate to refer directly to the ambient [ThemeData.inputDecorationTheme].
/// This decoration does not replace the ambient [InputDecorationTheme], it is
/// merged with it by [InputDecoration.applyDefaults]. Only the properties
/// that are left null here take their value from the ambient
/// [ThemeData.inputDecorationTheme]. So, for example, when the theme specifies
/// a border, passing an [InputDecoration] that leaves [InputDecoration.border]
/// null does not remove that border; pass `border: InputBorder.none` to opt
/// out of it explicitly.|
Closing in favour of flutter/packages#12493 — as the code-freeze bot notes, Material changes now belong in |
…DecorationTheme (#12493) `TextField.decoration`'s dartdoc describes what the decoration draws, but never mentions that the value passed here is *combined* with the ambient `InputDecorationTheme` rather than replacing it. `TextField` builds its effective decoration with `InputDecoration.applyDefaults` (`packages/material_ui/lib/src/text_field.dart`), and `applyDefaults` only substitutes properties that are null on the incoming `InputDecoration` — including `border: border ?? theme.border` (`packages/material_ui/lib/src/input_decorator.dart`). So a theme-provided border survives an `InputDecoration` that simply omits one, which is surprising if you read the property docs alone. That confusion is what flutter/flutter#159629 reports. This adds a paragraph to the `decoration` property documenting the merge and pointing at the explicit opt-out (`InputBorder.none`). This covers the documentation half of flutter/flutter#159629. The issue also proposes a `mergeWithTheme`-style flag on `InputDecoration`; that is an API proposal and is deliberately left out of this PR, so the issue should stay open. Originally opened against `flutter/flutter` as flutter/flutter#191260, and moved here after the code-freeze bot pointed out that Material changes now belong in `material_ui`. *Documentation-only change; no behavior change and no new tests.*
TextField.decoration's dartdoc describes what the decoration draws, but never mentions that the value passed here is combined with the ambientInputDecorationThemerather than replacing it.TextFieldbuilds its effective decoration withInputDecoration.applyDefaults:https://github.com/flutter/flutter/blob/7deb8a4d/packages/flutter/lib/src/material/text_field.dart#L1208-L1210
and
applyDefaultsonly substitutes properties that are null on the incomingInputDecoration(includingborder: border ?? theme.border). So a theme-provided border survives anInputDecorationthat simply omits one, which is surprising if you read the property docs alone — that confusion is what #159629 reports.This adds a paragraph to the
decorationproperty documenting the merge and pointing at the explicit opt-out (border: InputBorder.none).This covers the documentation half of #159629. The issue also proposes a
mergeWithTheme-style flag onInputDecoration; that is an API proposal and is deliberately left out of this PR, so the issue should stay open.Documentation-only change; no behavior change and no new tests.
Pre-launch Checklist
///).