Flutter 颤振原材料按钮赢得';我不能变得透明

Flutter 颤振原材料按钮赢得';我不能变得透明,flutter,dart,Flutter,Dart,我正在使用这个简单的带有图标的循环按钮。一个问题是,当没有设置颜色时,它将不尊重透明度 class CircularButtonWithIcon extends StatefulWidget { CircularButtonWithIcon({ Key key, @required this.onPress, this.padding, this.border, this.active = false, this.marginRight,

我正在使用这个简单的带有图标的循环按钮。一个问题是,当没有设置颜色时,它将不尊重透明度

class CircularButtonWithIcon extends StatefulWidget {
  CircularButtonWithIcon({
    Key key,
    @required this.onPress,
    this.padding,
    this.border,
    this.active = false,
    this.marginRight,
    this.marginLeft,
    this.icon,
    this.color,
    this.activeColor,
    this.text,
    this.splashColor,
    this.image,
    this.hasState,
    this.borderColor,
  }) : super(key: key);
  final double padding;
  final double border;
  final double marginRight;
  final double marginLeft;
  final Icon icon;
  final Image image;
  final Color color;
  final Color activeColor;
  final Color borderColor;
  final Widget text;
  final Color splashColor;
  final Function onPress;
  final bool active;
  final bool hasState;

  @override
  _CircularButtonWithIconState createState() => _CircularButtonWithIconState();
}

class _CircularButtonWithIconState extends State<CircularButtonWithIcon> {
  bool active;

  @override
  void initState() {
    super.initState();
    active = widget.active;
  }

  @override
  Widget build(BuildContext context) {
    return FittedBox(
      child: Container(
        margin: EdgeInsets.only(left: widget.marginLeft ?? 0, right: widget.marginRight ?? 0),
        child: RawMaterialButton(
          onPressed: () {
            setState(() {
              active = !active;    // don't use widget.active
            });
            if (widget.onPress != null) widget.onPress();
          },
          fillColor: active
              ? widget.activeColor ?? widget.color ?? Colors.transparent
              : widget.color ?? Colors.transparent,
          splashColor: widget.splashColor ?? Colors.grey,
          child: widget.text != null
              ? Container(
            child: widget.text,
          )
              : widget.image ?? widget.icon,
          //padding: EdgeInsets.all(15.0),
          padding: widget.padding != null ? EdgeInsets.all(widget.padding) : EdgeInsets.all(15.0),
          shape: CircleBorder(
            side: BorderSide(
                width: widget.border ?? 2.0,
                style: BorderStyle.solid,
                color: widget.borderColor ?? Colors.grey),
          ),
        ),
      ),
    );
  }
}
当没有设置颜色时,它应该是透明的

我这样做:

                  CircularButtonWithIcon(
                      padding: 10,
                      border: 3,
                      onPress: () => {},
                      icon: Icon(Icons.remove,
                          color: Color.green,
                          size: 60))
它得到的是一个彩色背景,而不是合并:


然而,它看起来只是背景,但颜色更暗。按钮是否可能在背景色上方添加阴影?我怎样才能删除它?我查看了按钮,在按钮主体上找不到与阴影效果相关的任何内容

容器(边距:EdgeInsets.all(64),装饰:BoxDecoration(border:border.all()),子项:RawMaterialButton(onPressed:()=>print('onPressed'),子项:SizedBox.expand(),),),
只起作用fine@pskink但是如果我必须添加颜色呢?如何基于布尔值禁用颜色?我必须在某些情况下使用透明
elevation:0.0
@pskink,谢谢
body:Container(边距:EdgeInsets.all(64),装饰:BoxDecoration(border:border.all()),child:RawMaterialButton(onPressed:()=>print('onPressed'),child:SizedBox.expand(),),
fine@pskink但是如果我必须添加颜色呢?如何基于布尔值禁用颜色?我必须在某些情况下使用透明
elevation:0.0
@pskink works,谢谢
                  CircularButtonWithIcon(
                      padding: 10,
                      border: 3,
                      onPress: () => {},
                      icon: Icon(Icons.remove,
                          color: Color.green,
                          size: 60))