Files
gopeed/ui/flutter_v2/lib/components/gp_gradient_button.dart
T
2025-09-29 20:13:30 +08:00

61 lines
1.7 KiB
Dart

import 'package:flutter/material.dart';
class GpGradientButton extends StatelessWidget {
final String text;
final VoidCallback onPressed;
final IconData? icon; // 添加可选图标参数
const GpGradientButton({
super.key,
required this.text,
required this.onPressed,
this.icon,
});
@override
Widget build(BuildContext context) {
return SizedBox(
width: 120,
height: 40,
child: ElevatedButton(
onPressed: onPressed,
style: ElevatedButton.styleFrom(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(143),
),
padding: EdgeInsets.zero,
backgroundColor: Colors.transparent,
),
child: Ink(
decoration: const BoxDecoration(
gradient: LinearGradient(
colors: [Color(0xFF3ACBBE), Color(0xFF2CDB90)],
begin: Alignment.centerLeft,
end: Alignment.centerRight,
),
borderRadius: BorderRadius.all(Radius.circular(143)),
),
child: Container(
alignment: Alignment.center,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
if (icon != null) Icon(icon, size: 16.0, color: Colors.white),
if (icon != null) const SizedBox(width: 4.0), // 图标和文本之间的间距
Text(
text,
style: const TextStyle(
fontSize: 16.0,
fontWeight: FontWeight.bold,
color: Color(0xFFFFFFFE),
),
),
],
),
),
),
),
);
}
}