From 18489fdd4905b11721e8e581f5a59606736f7c0b Mon Sep 17 00:00:00 2001 From: Abhishek Ghaskata Date: Sat, 15 May 2021 00:14:02 +0530 Subject: [PATCH] Added Alignment docs for FractionallySizedBox (#82539) --- packages/flutter/lib/src/widgets/basic.dart | 27 +++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/packages/flutter/lib/src/widgets/basic.dart b/packages/flutter/lib/src/widgets/basic.dart index 7d525f143d..e0b0057c44 100644 --- a/packages/flutter/lib/src/widgets/basic.dart +++ b/packages/flutter/lib/src/widgets/basic.dart @@ -2676,6 +2676,33 @@ class UnconstrainedBox extends StatelessWidget { /// /// {@youtube 560 315 https://www.youtube.com/watch?v=PEsY654EGZ0} /// +/// {@tool dartpad --template=stateless_widget_scaffold} +/// +/// This sample shows a [FractionallySizedBox] whose one child is 50% of +/// the box's size per the width and height factor parameters, and centered +/// within that box by the alignment parameter. +/// +/// ```dart +/// Widget build(BuildContext context) { +/// return SizedBox.expand( +/// child: FractionallySizedBox( +/// widthFactor: 0.5, +/// heightFactor: 0.5, +/// alignment: FractionalOffset.center, +/// child: DecoratedBox( +/// decoration: BoxDecoration( +/// border: Border.all( +/// color: Colors.blue, +/// width: 4, +/// ), +/// ), +/// ), +/// ), +/// ); +/// } +/// ``` +/// {@end-tool} +/// /// See also: /// /// * [Align], which sizes itself based on its child's size and positions