From 9b01d8a578532e1d011b1814715667968d9f0f32 Mon Sep 17 00:00:00 2001 From: Kate Lovett Date: Fri, 1 Mar 2019 15:46:58 -0800 Subject: [PATCH] Expanded Snippet for API Docs (#28681) * Added code snippet for Expanded class. ref:#21136 * Changed the code samples into snippet application samples. --- packages/flutter/lib/src/widgets/basic.dart | 77 +++++++++++++++++++++ 1 file changed, 77 insertions(+) diff --git a/packages/flutter/lib/src/widgets/basic.dart b/packages/flutter/lib/src/widgets/basic.dart index 9ffdbab56d..b318e4142d 100644 --- a/packages/flutter/lib/src/widgets/basic.dart +++ b/packages/flutter/lib/src/widgets/basic.dart @@ -4263,6 +4263,83 @@ class Flexible extends ParentDataWidget { /// [Flex] must contain only [StatelessWidget]s or [StatefulWidget]s (not other /// kinds of widgets, like [RenderObjectWidget]s). /// +/// {@tool snippet --template=stateless_widget_material} +/// This example shows how to use an [Expanded] widget in a [Column] so that +/// it's middle child, a [Container] here, expands to fill the space. +/// +/// ```dart +/// Widget build(BuildContext context) { +/// return Scaffold( +/// appBar: AppBar( +/// title: Text('Expanded Column Sample'), +/// ), +/// body: Center( +/// child: Column( +/// children: [ +/// Container( +/// color: Colors.red, +/// height: 100, +/// width: 100, +/// ), +/// Expanded( +/// child: Container( +/// color: Colors.blue, +/// width: 100, +/// ), +/// ), +/// Container( +/// color: Colors.red, +/// height: 100, +/// width: 100, +/// ), +/// ], +/// ), +/// ), +/// ); +/// } +/// ``` +/// {@end-tool} +/// +/// {@tool snippet --template=stateless_widget_material} +/// This example shows how to use an [Expanded] widget in a [Row] with multiple +/// children expanded, utilizing the [flex] factor to prioritize available space. +/// +/// ```dart +/// Widget build(BuildContext context) { +/// return Scaffold( +/// appBar: AppBar( +/// title: Text('Expanded Row Sample'), +/// ), +/// body: Center( +/// child: Row( +/// children: [ +/// Expanded( +/// flex: 2, +/// child: Container( +/// color: Colors.red, +/// height: 100, +/// ), +/// ), +/// Container( +/// color: Colors.blue, +/// height: 100, +/// width: 50, +/// ), +/// Expanded( +/// flex: 1, +/// child: Container( +/// color: Colors.red, +/// height: 100, +/// ), +/// ), +/// ], +/// ), +/// ), +/// ); +/// } +/// ``` +/// {@end-tool} +/// /// See also: /// /// * [Flexible], which does not force the child to fill the available space.