creek
The AI Image Editor of 2030git clone https://github.com/maydayv7/creek
lib/ui/widgets/primary_button.dart (2023B)
1import 'package:flutter/material.dart';
2import 'package:flutter_svg/flutter_svg.dart';
3import 'package:creekui/ui/styles/variables.dart';
4
5class PrimaryButton extends StatelessWidget {
6 final String text;
7 final VoidCallback? onPressed;
8 final bool isLoading;
9 final String? iconPath;
10 final Color? backgroundColor;
11
12 const PrimaryButton({
13 super.key,
14 required this.text,
15 this.onPressed,
16 this.isLoading = false,
17 this.iconPath,
18 this.backgroundColor,
19 });
20
21 @override
22 Widget build(BuildContext context) {
23 return SizedBox(
24 width: double.infinity,
25 child: ElevatedButton(
26 onPressed: isLoading ? null : onPressed,
27 style: ElevatedButton.styleFrom(
28 backgroundColor: backgroundColor ?? Variables.textPrimary,
29 foregroundColor: Colors.white,
30 padding: const EdgeInsets.symmetric(vertical: 12),
31 shape: RoundedRectangleBorder(
32 borderRadius: BorderRadius.circular(100),
33 ),
34 elevation: 0,
35 ),
36 child:
37 isLoading
38 ? const SizedBox(
39 height: 20,
40 width: 20,
41 child: CircularProgressIndicator(
42 color: Colors.white,
43 strokeWidth: 2,
44 ),
45 )
46 : Row(
47 mainAxisAlignment: MainAxisAlignment.center,
48 children: [
49 Text(text, style: Variables.buttonTextStyle),
50 if (iconPath != null) ...[
51 const SizedBox(width: 12),
52 SvgPicture.asset(
53 iconPath!,
54 width: 18,
55 height: 18,
56 colorFilter: const ColorFilter.mode(
57 Colors.white,
58 BlendMode.srcIn,
59 ),
60 ),
61 ],
62 ],
63 ),
64 ),
65 );
66 }
67}