How to add shadow to a container in flutter?

This Article is posted by seven.srikanth at 11/23/2022 1:17:36 AM



<p>Let's is how to add shadow to a container in flutter.</p> <p>Here is the output of this example. You can observe the shadow below the container.</p> <p>![](../../../Uploads/60d77c0c-ebaa-4d5d-bf3e-4b096f4fa5d4.jpgwidth="50%height="auto](</p> <p>For achieving this, we can use PhysicalModel widget. This widget representing a physical layer that clips its children to a shape.</p> <p>Here is the complete code from main.dart file for this example.</p> <p id="4ec9b0;](MyApp());" color:="" color:=>color: #9cdcfe;](args) </p> <p id="9cdcfe;](key" color:= color:=>color: #569cd6;](class color: #4ec9b0;](MyApp color: #569cd6;](extends color: #4ec9b0;](StatelessWidget ); color: #9cdcfe;](@ color: #9cdcfe;](override</p> <p>color: #4ec9b0;](Widget color: #dcdcaa;](build(color: #4ec9b0;](BuildContext color: #9cdcfe;](context) { color: #c586c0;](return color: #569cd6;](const color: #4ec9b0;](MaterialApp( color: #9cdcfe;](home: color: #4ec9b0;](Scaffold( color: #9cdcfe;](body: color: #4ec9b0;](MyLayoutWidget(), ), ); } }</p> <p id="9cdcfe;](key," color:= color:="" color:="">color: #569cd6;](class color: #4ec9b0;](MyLayoutWidget color: #569cd6;](extends color: #4ec9b0;](StatelessWidget ); color: #9cdcfe;](@ color: #9cdcfe;](override</p> <p>color: #4ec9b0;](Widget color: #dcdcaa;](build(color: #4ec9b0;](BuildContext color: #9cdcfe;](context) { color: #c586c0;](return color: #4ec9b0;](Center( color: #9cdcfe;](child: color: #4ec9b0;](PhysicalModel( color: #9cdcfe;](color: color: #4ec9b0;](Colors.color: #9cdcfe;](black, color: #9cdcfe;](shadowColor: color: #4ec9b0;](Colors.color: #9cdcfe;](blue, color: #9cdcfe;](elevation: color: #b5cea8;](20.0, color: #9cdcfe;](child: color: #4ec9b0;](Container( color: #9cdcfe;](height: color: #b5cea8;](100, color: #9cdcfe;](width: color: #b5cea8;](100, color: #9cdcfe;](color: color: #4ec9b0;](Colors.color: #9cdcfe;](blue, ), ), ); } } ` Thanks,Srikanth</p>


Tags: Add shadow to a container;








0 Comments
Login to comment.
Recent Comments