颤振-如何分配更多的水龙头区域

Is it possible to create a widget that has more tap area than its actual size? Want:enter image description here

  • 黑色区域是按钮的大小
  • 红色区域不填充,不包含在按钮的大小中,但是单击它会触发按钮
评论
  • 占领网吧
    占领网吧 回复

    当然可以,您尝试过Material Button吗?

     class CustomButton extends StatelessWidget {
      CustomButton({this.text});
      String text = "test";
    
      @override
      Widget build(BuildContext context) {
        return Container(
          height: 60,
          width: 280,
          child: MaterialButton(
            onPressed: () {},
            child: Text(
              text.toString(),
              style: textStyle,
            ),
          ),
          decoration: boxDecoration.copyWith(
            shape: BoxShape.rectangle,
            borderRadius: BorderRadius.circular(30),
          ),
        );
      }
    }