button2small function

dynamic button2small(
  1. String text,
  2. Function _callback, {
  3. bool enable = true,
  4. Color? color,
})

Implementation

button2small(String text, Function _callback, {bool enable = true, Color? color}){
  var _color = aTheme.mainColor;
  if (color != null) _color = color;
  return Stack(
    children: <Widget>[
      Container(
          decoration: BoxDecoration(
            color: (enable) ? _color : Colors.grey.withOpacity(0.5),
            borderRadius: BorderRadius.circular(aTheme.radius),
          ),
          child: Stack(
            children: [
              Container(
                padding: EdgeInsets.only(top: 5, bottom: 5, left: 10, right: 10),
                child: Text(text, style: aTheme.style12W600White, 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
                      )),
                )
            ],
        )
      ),
    ],
  );
}