Flutter BoxShadow(繪製陰影)+Container+BoxDecoration
勿以善小而不為,勿以惡小而為之。——劉備
陰影(BoxShadow)+Y軸偏移量(Offset)
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Container(
padding: EdgeInsets.all(20.0),
margin: EdgeInsets.all(20.0),
decoration: new BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(10.0)),
border: new Border.all(width: 1, color: Colors.green,),
boxShadow: [
BoxShadow(
color: Colors.green,
offset: Offset(0.0, 6.0), //陰影y軸偏移量
blurRadius: 0, //陰影模糊程度
spreadRadius: 0 //陰影擴散程度
)
],
),
child: Text("BoxShadow(繪製陰影)+Container+BoxDecoration"),
));
}
}
陰影(BoxShadow)+X軸偏移量(Offset)
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Container(
padding: EdgeInsets.all(20.0),
margin: EdgeInsets.all(20.0),
decoration: new BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(10.0)),
border: new Border.all(width: 1, color: Colors.black,),
boxShadow: [
BoxShadow(
color: Colors.black,
offset: Offset(6.0, 0.0), //陰影x軸偏移量
blurRadius: 0, //陰影模糊程度
spreadRadius: 0 //陰影擴散程度
)
],
),
child: Text("BoxShadow(繪製陰影)+Container+BoxDecoration"),
));
}
}
陰影(BoxShadow)+XY軸偏移量(Offset)
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Container(
padding: EdgeInsets.all(20.0),
margin: EdgeInsets.all(20.0),
decoration: new BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(10.0)),
border: new Border.all(width: 1, color: Colors.green,),
boxShadow: [
BoxShadow(
color: Colors.green,
offset: Offset(6.0, 6.0), //陰影x軸偏移量
blurRadius: 0, //陰影模糊程度
spreadRadius: 0 //陰影擴散程度
)
],
),
child: Text("BoxShadow(繪製陰影)+Container+BoxDecoration"),
));
}
}
陰影(BoxShadow)+XY軸偏移量(Offset) +模糊(blurRadius)
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Container(
padding: EdgeInsets.all(20.0),
margin: EdgeInsets.all(20.0),
decoration: new BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(10.0)),
border: new Border.all(width: 1, color: Colors.black,),
boxShadow: [
BoxShadow(
color: Colors.black,
offset: Offset(-6.0, 6.0), //陰影x軸偏移量
blurRadius: 10, //陰影模糊程度
spreadRadius: 0 //陰影擴散程度
)
],
),
child: Text("BoxShadow(繪製陰影)+Container+BoxDecoration"),
));
}
}
陰影(BoxShadow)+XY軸偏移量(Offset) +模糊(blurRadius)+擴散(spreadRadius)
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Container(
padding: EdgeInsets.all(20.0),
margin: EdgeInsets.all(20.0),
decoration: new BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(10.0)),
border: new Border.all(width: 1, color: Colors.green,),
boxShadow: [
BoxShadow(
color: Colors.green,
offset: Offset(-6.0, 6.0), //陰影x軸偏移量
blurRadius: 10, //陰影模糊程度
spreadRadius: 10 //陰影擴散程度
)
],
),
child: Text("BoxShadow(繪製陰影)+Container+BoxDecoration"),
));
}
}
withOpacity淡化陰影
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text(widget.title),
),
body: Container(
padding: EdgeInsets.all(20.0),
margin: EdgeInsets.all(20.0),
decoration: new BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(10.0)),
border: new Border.all(width: 0, color: Colors.red,),
boxShadow: [
BoxShadow(
color: Colors.red.withOpacity(0.2),
offset: Offset(-6.0, 6.0), //陰影x軸偏移量
blurRadius: 10, //陰影模糊程度
spreadRadius: 5 //陰影擴散程度
)
],
),
child: Text("BoxShadow(繪製陰影)+Container+BoxDecoration"),
));
}
}
通過英文單詞理解:
box-盒子
shadow-陰影
blur-模糊
spread-傳播擴散
我們可以理解為: 這樣一個裝有widget的盒子的外面需要新增陰影效果,我們可以設定陰影擴散範圍和陰影模糊程度.
相關文章
- Flutter繪製barchartFlutter
- Flutter自定義繪製(1)- 繪製基礎Flutter
- css圖片陰影、文字陰影CSS
- 利用canvas陰影功能與雙線技巧繪製軌道交通大屏專案效果Canvas
- Flutter 自定義繪製 ViewFlutterView
- Flutter框架分析(七)-- 繪製Flutter框架
- Flutter渲染之繪製上屏Flutter
- Flutter的渲染繪製概述Flutter
- Flutter 中如何繪製動畫Flutter動畫
- flutter: 相鄰控制元件陰影被遮蓋Flutter控制元件
- boder 陰影
- 一、Flutter 之影象繪製原理Flutter
- Flutter之UI繪製流程二FlutterUI
- Flutter RenderBox指南——繪製篇Flutter
- Flutter的繪製流程簡述Flutter
- 假陰影,低開銷的陰影實現方式
- Flutter 圖表繪製解密(charts_flutter 的使用)Flutter解密
- [譯]Flutter是如何繪製文字的Flutter
- flutter: 視窗初始與繪製流程Flutter
- Flutter自定義繪製Widget初探Flutter
- 陰影進階,實現更加的立體的陰影效果!
- 簡單陰影分析
- 【CSS】曲線陰影CSS
- view邊框陰影View
- 紛爭再起:Flutter-UI繪製解析FlutterUI
- Flutter繪製-08-龍捲風效果Flutter
- Flutter繪製-05-shader專項Flutter
- Flutter佈局和繪製流程淺析Flutter
- Flutter渲染之繪製啟動及layoutFlutter
- CSS 陰影進階,實現更加的立體的陰影效果!CSS
- Shadow Map(陰影貼圖)跟Soft Shadows(軟陰影)
- 使用 Flutter 繪製圖表(二)餅狀圖?Flutter
- 使用 Flutter 繪製圖表(一)柱狀圖?Flutter
- flutter 用 CustomPaint 繪製自定義圖案FlutterAI
- canvas設定陰影效果Canvas
- WPF 實現陰影效果
- HTML中的盒子陰影HTML
- Flutter小小實踐——KLine 繪製篇(三)Flutter