From acbd2801485d79cedeebae29537fa5fb7b21297b Mon Sep 17 00:00:00 2001 From: Mohammad Ghalayini Date: Thu, 15 Jul 2021 19:21:02 +0300 Subject: [PATCH] Add an Interactive Example for PhysicalShape (#86423) --- packages/flutter/lib/src/widgets/basic.dart | 41 +++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/packages/flutter/lib/src/widgets/basic.dart b/packages/flutter/lib/src/widgets/basic.dart index 72e031355ac..844b3a7eaa8 100644 --- a/packages/flutter/lib/src/widgets/basic.dart +++ b/packages/flutter/lib/src/widgets/basic.dart @@ -1049,6 +1049,47 @@ class PhysicalModel extends SingleChildRenderObjectWidget { /// [PhysicalModel] does the same but only supports shapes that can be expressed /// as rectangles with rounded corners. /// +/// {@tool dartpad --template=stateless_widget_material} +/// +/// This example shows how to use a [PhysicalShape] on a centered [SizedBox] +/// to clip it to a rounded rectangle using a [ShapeBorderClipper] and give it +/// an orange color along with a shadow. +/// +/// ```dart +/// Widget build(BuildContext context) { +/// return Scaffold( +/// appBar: AppBar( +/// title: const Text('PhysicalShape Sample'), +/// ), +/// body: Center( +/// child: PhysicalShape( +/// elevation: 5.0, +/// child: const SizedBox( +/// child: Center( +/// child: Text( +/// 'Hello, World!', +/// style: TextStyle( +/// color: Colors.white, +/// fontSize: 20.0, +/// ), +/// ), +/// ), +/// height: 200.0, +/// width: 200.0, +/// ), +/// clipper: ShapeBorderClipper( +/// shape: RoundedRectangleBorder( +/// borderRadius: BorderRadius.circular(10.0), +/// ) +/// ), +/// color: Colors.orange, +/// ), +/// ), +/// ); +/// } +/// ``` +/// {@end-tool} +/// /// See also: /// /// * [ShapeBorderClipper], which converts a [ShapeBorder] to a [CustomClipper], as