Unverified Commit 89204384 authored by Shi-Hao Hong's avatar Shi-Hao Hong Committed by GitHub

`child` param doc update in Ink and Ink.image (#35211)

* Add doc suggesting Container for BoxDecorations that have no child widget
parent a1d3edc4
...@@ -110,11 +110,14 @@ class Ink extends StatefulWidget { ...@@ -110,11 +110,14 @@ class Ink extends StatefulWidget {
/// ///
/// The [height] and [width] values include the [padding]. /// The [height] and [width] values include the [padding].
/// ///
/// The `color` argument is a shorthand for `decoration: new /// The `color` argument is a shorthand for
/// BoxDecoration(color: color)`, which means you cannot supply both a `color` /// `decoration: BoxDecoration(color: color)`, which means you cannot supply
/// and a `decoration` argument. If you want to have both a `color` and a /// both a `color` and a `decoration` argument. If you want to have both a
/// `decoration`, you can pass the color as the `color` argument to the /// `color` and a `decoration`, you can pass the color as the `color`
/// `BoxDecoration`. /// argument to the `BoxDecoration`.
///
/// If there is no intention to render anything on this decoration, consider
/// using a [Container] with a [BoxDecoration] instead.
Ink({ Ink({
Key key, Key key,
this.padding, this.padding,
...@@ -127,7 +130,7 @@ class Ink extends StatefulWidget { ...@@ -127,7 +130,7 @@ class Ink extends StatefulWidget {
assert(decoration == null || decoration.debugAssertIsValid()), assert(decoration == null || decoration.debugAssertIsValid()),
assert(color == null || decoration == null, assert(color == null || decoration == null,
'Cannot provide both a color and a decoration\n' 'Cannot provide both a color and a decoration\n'
'The color argument is just a shorthand for "decoration: new BoxDecoration(color: color)".' 'The color argument is just a shorthand for "decoration: BoxDecoration(color: color)".'
), ),
decoration = decoration ?? (color != null ? BoxDecoration(color: color) : null), decoration = decoration ?? (color != null ? BoxDecoration(color: color) : null),
super(key: key); super(key: key);
...@@ -136,13 +139,16 @@ class Ink extends StatefulWidget { ...@@ -136,13 +139,16 @@ class Ink extends StatefulWidget {
/// a [Material]. /// a [Material].
/// ///
/// This argument is a shorthand for passing a [BoxDecoration] that has only /// This argument is a shorthand for passing a [BoxDecoration] that has only
/// its [BoxDecoration.image] property set to the [new Ink] constructor. The /// its [BoxDecoration.image] property set to the [Ink] constructor. The
/// properties of the [DecorationImage] of that [BoxDecoration] are set /// properties of the [DecorationImage] of that [BoxDecoration] are set
/// according to the arguments passed to this method. /// according to the arguments passed to this method.
/// ///
/// The `image` argument must not be null. The `alignment`, `repeat`, and /// The `image` argument must not be null. If there is no
/// `matchTextDirection` arguments must not be null either, but they have /// intention to render anything on this image, consider using a
/// default values. /// [Container] with a [BoxDecoration.image] instead.
///
/// The `alignment`, `repeat`, and `matchTextDirection` arguments must not
/// be null either, but they have default values.
/// ///
/// See [paintImage] for a description of the meaning of these arguments. /// See [paintImage] for a description of the meaning of these arguments.
Ink.image({ Ink.image({
...@@ -194,8 +200,8 @@ class Ink extends StatefulWidget { ...@@ -194,8 +200,8 @@ class Ink extends StatefulWidget {
/// constructor: set the `color` argument instead of the `decoration` /// constructor: set the `color` argument instead of the `decoration`
/// argument. /// argument.
/// ///
/// A shorthand for specifying just an image is also available using the [new /// A shorthand for specifying just an image is also available using the
/// Ink.image] constructor. /// [Ink.image] constructor.
final Decoration decoration; final Decoration decoration;
/// A width to apply to the [decoration] and the [child]. The width includes /// A width to apply to the [decoration] and the [child]. The width includes
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment