Example 1: flutter add shadow to container
Container(
decoration: BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.8),
spreadRadius: 10,
blurRadius: 5,
offset: Offset(0, 7),
),
],
),
child: Image.asset(chocolateImage),
)
Example 2: shadow container flutter
BoxDecoration(
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 5,
blurRadius: 7,
offset: Offset(0, 3),
),
],
)
Example 3: how to add box shadow in flutter
new Container(
height: 200.0,
decoration: new BoxDecoration(
boxShadow: [
color: Colors.white,
BoxShadow(
color: Colors.red,
blurRadius: 25.0,
spreadRadius: 5.0,
offset: Offset(
15.0,
15.0,
),
)
],
),
child: new Text("Hello world"),
);
Example 4: how to add elevation to container flutter
import "package:flutter/material.dart";
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
Widget build(BuildContext context) {
return MaterialApp(
home: HomePage(),
);
}
}
class HomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Padding(
padding: const EdgeInsets.all(30.0),
child: ClipRRect(
borderRadius: BorderRadius.circular(5.0),
child: Container(
height: 100.0,
margin: const EdgeInsets.only(bottom: 6.0),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(5.0),
color: Colors.white,
boxShadow: [
BoxShadow(
color: Colors.grey,
offset: Offset(0.0, 1.0),
blurRadius: 6.0,
),
],
),
),
),
),
),
);
}
}