You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

53 lines
1.6 KiB

import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
class CustomButton extends StatelessWidget {
final String text; // 按钮文字
final VoidCallback onTap; // 点击事件回调
const CustomButton({super.key, required this.text, required this.onTap});
@override
Widget build(BuildContext context) {
return Container(
width: 51.w, // 宽度
height: 26.h, // 高度
decoration: BoxDecoration(
color: const Color(0xFF3FA6FC), // 设置背景色
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8), // 左上角圆角
topRight: Radius.circular(0), // 右上角圆角
bottomLeft: Radius.circular(0), // 左下角圆角
bottomRight: Radius.circular(8), // 右下角圆角
),
),
child: Stack(
children: [
Center(
child: Text(
text, // 动态按钮文字
style: TextStyle(
fontSize: 12.sp, // 字体大小
color: Colors.white, // 字体颜色
fontWeight: FontWeight.bold, // 字体加粗
),
),
),
Material(
color: Colors.transparent, // 背景透明
child: InkWell(
borderRadius: BorderRadius.only(
topLeft: Radius.circular(8), // 同容器圆角
topRight: Radius.circular(0),
bottomLeft: Radius.circular(0),
bottomRight: Radius.circular(8),
),
onTap: onTap, // 动态点击事件
),
),
],
),
);
}
}