mirror of
https://github.com/GopeedLab/gopeed.git
synced 2026-11-06 00:25:43 +00:00
61 lines
1.7 KiB
Dart
61 lines
1.7 KiB
Dart
import 'package:flutter/material.dart';
|
|
|
|
class GradientButton extends StatelessWidget {
|
|
final String text;
|
|
final VoidCallback onPressed;
|
|
final IconData? icon; // 添加可选图标参数
|
|
|
|
const GradientButton({
|
|
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),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
),
|
|
),
|
|
);
|
|
}
|
|
}
|