Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit acbd280

Browse files
author
Mohammad Ghalayini
authoredJul 15, 2021
Add an Interactive Example for PhysicalShape (flutter#86423)
1 parent 0d7e679 commit acbd280

File tree

1 file changed

+41
-0
lines changed

1 file changed

+41
-0
lines changed
 

‎packages/flutter/lib/src/widgets/basic.dart

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1049,6 +1049,47 @@ class PhysicalModel extends SingleChildRenderObjectWidget {
10491049
/// [PhysicalModel] does the same but only supports shapes that can be expressed
10501050
/// as rectangles with rounded corners.
10511051
///
1052+
/// {@tool dartpad --template=stateless_widget_material}
1053+
///
1054+
/// This example shows how to use a [PhysicalShape] on a centered [SizedBox]
1055+
/// to clip it to a rounded rectangle using a [ShapeBorderClipper] and give it
1056+
/// an orange color along with a shadow.
1057+
///
1058+
/// ```dart
1059+
/// Widget build(BuildContext context) {
1060+
/// return Scaffold(
1061+
/// appBar: AppBar(
1062+
/// title: const Text('PhysicalShape Sample'),
1063+
/// ),
1064+
/// body: Center(
1065+
/// child: PhysicalShape(
1066+
/// elevation: 5.0,
1067+
/// child: const SizedBox(
1068+
/// child: Center(
1069+
/// child: Text(
1070+
/// 'Hello, World!',
1071+
/// style: TextStyle(
1072+
/// color: Colors.white,
1073+
/// fontSize: 20.0,
1074+
/// ),
1075+
/// ),
1076+
/// ),
1077+
/// height: 200.0,
1078+
/// width: 200.0,
1079+
/// ),
1080+
/// clipper: ShapeBorderClipper(
1081+
/// shape: RoundedRectangleBorder(
1082+
/// borderRadius: BorderRadius.circular(10.0),
1083+
/// )
1084+
/// ),
1085+
/// color: Colors.orange,
1086+
/// ),
1087+
/// ),
1088+
/// );
1089+
/// }
1090+
/// ```
1091+
/// {@end-tool}
1092+
///
10521093
/// See also:
10531094
///
10541095
/// * [ShapeBorderClipper], which converts a [ShapeBorder] to a [CustomClipper], as

0 commit comments

Comments
 (0)