From 5b3e933c7f38c0845593cdfc0ee1d31cc6407a1c Mon Sep 17 00:00:00 2001 From: Kartik Sharma Date: Wed, 23 Jan 2019 02:01:10 +0530 Subject: [PATCH] Added Sample code for Stack widget (#26586) --- packages/flutter/lib/src/widgets/basic.dart | 68 +++++++++++++++++++++ 1 file changed, 68 insertions(+) diff --git a/packages/flutter/lib/src/widgets/basic.dart b/packages/flutter/lib/src/widgets/basic.dart index 9887a1f670..36a26e0b08 100644 --- a/packages/flutter/lib/src/widgets/basic.dart +++ b/packages/flutter/lib/src/widgets/basic.dart @@ -2851,6 +2851,74 @@ class ListBody extends MultiChildRenderObjectWidget { /// [CustomMultiChildLayout] instead. In particular, when using a [Stack] you /// 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: [ +/// 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: [ +/// 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: [ +/// Colors.black.withAlpha(0), +/// Colors.black12, +/// Colors.black45 +/// ], +/// ), +/// ), +/// child: Text( +/// "Foreground Text", +/// style: TextStyle(color: Colors.white, fontSize: 20.0), +/// ), +/// ), +/// ], +/// ), +/// ) +/// ``` +/// {@end-tool} +/// /// See also: /// /// * [Align], which sizes itself based on its child's size and positions