Added Sample code for Stack widget (#26586)
This commit is contained in:
parent
890085e9b0
commit
5b3e933c7f
@ -2851,6 +2851,74 @@ class ListBody extends MultiChildRenderObjectWidget {
|
|||||||
/// [CustomMultiChildLayout] instead. In particular, when using a [Stack] you
|
/// [CustomMultiChildLayout] instead. In particular, when using a [Stack] you
|
||||||
/// can't position children relative to their size or the stack's own size.
|
/// can't position children relative to their size or the stack's own size.
|
||||||
///
|
///
|
||||||
|
/// {@tool sample}
|
||||||
|
///
|
||||||
|
/// Using a [Stack] you can position widgets over one another.
|
||||||
|
///
|
||||||
|
/// ```dart
|
||||||
|
/// Stack(
|
||||||
|
/// children: <Widget>[
|
||||||
|
/// Container(
|
||||||
|
/// width: 100,
|
||||||
|
/// height: 100,
|
||||||
|
/// color: Colors.red,
|
||||||
|
/// ),
|
||||||
|
/// Container(
|
||||||
|
/// width: 90,
|
||||||
|
/// height: 90,
|
||||||
|
/// color: Colors.green,
|
||||||
|
/// ),
|
||||||
|
/// Container(
|
||||||
|
/// width: 80,
|
||||||
|
/// height: 80,
|
||||||
|
/// color: Colors.blue,
|
||||||
|
/// ),
|
||||||
|
/// ],
|
||||||
|
/// )
|
||||||
|
/// ```
|
||||||
|
/// {@end-tool}
|
||||||
|
///
|
||||||
|
/// {@tool sample}
|
||||||
|
///
|
||||||
|
/// This example shows how [Stack] can be used to enhance text visibility
|
||||||
|
/// by adding gradient backdrops.
|
||||||
|
///
|
||||||
|
/// ```dart
|
||||||
|
/// SizedBox(
|
||||||
|
/// width: 250,
|
||||||
|
/// height: 250,
|
||||||
|
/// child: Stack(
|
||||||
|
/// children: <Widget>[
|
||||||
|
/// Container(
|
||||||
|
/// width: 250,
|
||||||
|
/// height: 250,
|
||||||
|
/// color: Colors.white,
|
||||||
|
/// ),
|
||||||
|
/// Container(
|
||||||
|
/// padding: EdgeInsets.all(5.0),
|
||||||
|
/// alignment: Alignment.bottomCenter,
|
||||||
|
/// decoration: BoxDecoration(
|
||||||
|
/// gradient: LinearGradient(
|
||||||
|
/// begin: Alignment.topCenter,
|
||||||
|
/// end: Alignment.bottomCenter,
|
||||||
|
/// colors: <Color>[
|
||||||
|
/// Colors.black.withAlpha(0),
|
||||||
|
/// Colors.black12,
|
||||||
|
/// Colors.black45
|
||||||
|
/// ],
|
||||||
|
/// ),
|
||||||
|
/// ),
|
||||||
|
/// child: Text(
|
||||||
|
/// "Foreground Text",
|
||||||
|
/// style: TextStyle(color: Colors.white, fontSize: 20.0),
|
||||||
|
/// ),
|
||||||
|
/// ),
|
||||||
|
/// ],
|
||||||
|
/// ),
|
||||||
|
/// )
|
||||||
|
/// ```
|
||||||
|
/// {@end-tool}
|
||||||
|
///
|
||||||
/// See also:
|
/// See also:
|
||||||
///
|
///
|
||||||
/// * [Align], which sizes itself based on its child's size and positions
|
/// * [Align], which sizes itself based on its child's size and positions
|
||||||
|
Loading…
x
Reference in New Issue
Block a user