From b2026572db51fd73aa7de8f696f6ab6cfedd80f9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Sharma?= <737941+loic-sharma@users.noreply.github.com> Date: Tue, 22 Oct 2024 15:20:02 -0700 Subject: [PATCH] Add example to Directionality docs (#157230) --- packages/flutter/lib/src/widgets/basic.dart | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/packages/flutter/lib/src/widgets/basic.dart b/packages/flutter/lib/src/widgets/basic.dart index 5b37a78bcd..7b2e53e11b 100644 --- a/packages/flutter/lib/src/widgets/basic.dart +++ b/packages/flutter/lib/src/widgets/basic.dart @@ -150,6 +150,22 @@ abstract class _UbiquitousInheritedWidget extends InheritedWidget { /// /// For example, [Padding] depends on the [Directionality] to resolve /// [EdgeInsetsDirectional] objects into absolute [EdgeInsets] objects. +/// +/// {@tool snippet} +/// +/// This example uses a right-to-left [TextDirection] and draws a blue box with +/// a right margin of 8 pixels. +/// +/// ```dart +/// Directionality( +/// textDirection: TextDirection.rtl, +/// child: Container( +/// margin: const EdgeInsetsDirectional.only(start: 8), +/// color: Colors.blue, +/// ), +/// ) +/// ``` +/// {@end-tool} class Directionality extends _UbiquitousInheritedWidget { /// Creates a widget that determines the directionality of text and /// text-direction-sensitive render objects.