【发布时间】:2021-08-09 19:27:25
【问题描述】:
【问题讨论】:
标签: flutter user-interface containers
【问题讨论】:
标签: flutter user-interface containers
这不是 3D 的东西。它可以通过使用Container 小部件的decoration 的boxShadow 属性轻松实现。
然后,您可以使用color、blurRadius 之类的东西来获得所需的效果。
示例代码:
class Shadow extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: Text('Shadow')),
body: Container(
color: Colors.black,
child: Center(
child: Container(
width: 300,
height: 300,
decoration: BoxDecoration(
color: Colors.blue,
borderRadius: BorderRadius.circular(40),
boxShadow: [
BoxShadow(
color: Colors.blue.withOpacity(0.5),
offset: Offset(0, 25),
blurRadius: 3,
spreadRadius: -10)
],
),
),
),
),
);
}
}
输出
【讨论】: