【发布时间】:2020-10-05 17:18:52
【问题描述】:
作为初学者,我一直在尝试制作一个新应用。所以,给事物添加阴影对我来说是全新的。
所以,下面是我的代码:
Container(
child: Row(
mainAxisAlignment: MainAxisAlignment.start,
children: <Widget>[
ClipOval(
child: Material(
color: Colors.white, // button color
child: InkWell(
// splashColor: Colors.red, // inkwell color
child: SizedBox(
width: 46, height: 46, child: Icon(Icons.menu,color: Colors.red,),),
onTap: () {},
),
),
),
],
),
),
以下是模拟:
【问题讨论】:
-
不需要 ClipOval,查看api.flutter.dev/flutter/material/Material/type.html
-
因为我不知道如何使用
type属性。你能举个例子吗,我可以试试。 -
child: Material( type: MaterialType.circle, clipBehavior: Clip.antiAlias, elevation: 4.0, color: Colors.white, child: InkWell( splashColor: Colors.orange, highlightColor: Colors.transparent, onTap: () {}, child: SizedBox( width: 46, height: 46, child: Icon(Icons.menu, color: Colors.red,), ), ), ), -
或者
child: Container( width: 46, height: 46, decoration: ShapeDecoration( shape: CircleBorder(), shadows: [ BoxShadow(color: Colors.black, blurRadius: 4, offset: Offset(2, 2)), ], ), child: Material( shape: CircleBorder(), clipBehavior: Clip.antiAlias, color: Colors.white, child: InkWell( splashColor: Colors.orange, highlightColor: Colors.transparent, onTap: () {}, child: Icon(Icons.menu, color: Colors.red,), ), ), ),如果你想定义自己的影子 -
当然这两个版本都没有使用任何
ClipOval