import 'package:flutter/material.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; class ButtonForBlock extends StatefulWidget { final String title; final double? width; final double? height; final void Function()? onTap; final double? fontSize; final Color? bgColor; final BoxBorder? border; final double? radius; const ButtonForBlock({ Key? key, required this.title, this.onTap, this.width, this.height, this.fontSize, this.bgColor=const Color(0xFF00aaFF), this.border, this.radius, }) : super(key: key); @override State createState() => _ButtonForBlockState(); } class _ButtonForBlockState extends State { late bool isOn = false; @override Widget build(BuildContext context) { return GestureDetector( onTap: widget.onTap, onTapDown: (e)=>{setState(()=>{isOn=true})}, onTapUp: (e)=>{setState(()=>{isOn=false})}, onTapCancel: ()=>{setState(()=>{isOn=false})}, child: Container( height: widget.height ?? 35.h, alignment: Alignment.center, width: widget.width ?? 280.w, decoration: BoxDecoration( color: isOn? const Color(0xff007ab6): widget.bgColor, borderRadius: BorderRadius.circular(widget.radius ?? (widget.height != null? widget.height!/2: 35.h/2)), border: widget.border ), child: Text(widget.title, style: TextStyle(color: Colors.white, fontSize: widget.fontSize ?? 15.sp)), ), ); } }