Expanded Snippet for API Docs (#28681)
* Added code snippet for Expanded class. ref:#21136 * Changed the code samples into snippet application samples.
This commit is contained in:
@@ -4263,6 +4263,83 @@ class Flexible extends ParentDataWidget<Flex> {
|
||||
/// [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: <Widget>[
|
||||
/// 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: <Widget>[
|
||||
/// 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.
|
||||
|
||||
Reference in New Issue
Block a user