button2 function

dynamic button2(
  1. String text,
  2. Color color,
  3. dynamic _callback(), {
  4. bool enable = true,
  5. TextStyle? style,
  6. double? radius,
  7. double? width = double.maxFinite,
  8. EdgeInsetsGeometry? padding,
})

Implementation

button2(String text, Color color, Function() _callback,
    {
      bool enable = true,
      TextStyle? style, double? radius,
      double? width = double.maxFinite,
      EdgeInsetsGeometry? padding,
    }){
  return Stack(
    children: <Widget>[
      Container(
          width: width,
          padding: padding ?? EdgeInsets.only(top: 10, bottom: 10, left: 5, right: 5),
          decoration: BoxDecoration(
            color: (enable) ? color : Colors.grey.withOpacity(0.5),
            borderRadius: BorderRadius.circular(radius ?? aTheme.radius),
          ),
          child: FittedBox(fit: BoxFit.scaleDown,
              child: Text(text, style: style ?? aTheme.style14W600White,
                textAlign: TextAlign.center, overflow: TextOverflow.ellipsis,))
      ),
      if (enable)
        Positioned.fill(
          child: Material(
              color: Colors.transparent,
              clipBehavior: Clip.hardEdge,
              shape: RoundedRectangleBorder(borderRadius:BorderRadius.circular(aTheme.radius) ),
              child: InkWell(
                splashColor: Colors.black.withOpacity(0.2),
                onTap: (){
                  _callback();
                }, // needed
              )),
        )
    ],
  );
}