Primary Button Code

import 'package:flutter/material.dart';
import 'package:google_fonts/google_fonts.dart';

class PrimaryButton extends StatelessWidget {
  final String text;
  final VoidCallback onTap; // Use VoidCallback for consistency
  final Widget? icon;
  final Color color;
  final double width;
  final double height;
  final double fontSize;
  final double spaceBetweenIconAndText;
  final double borderRadius;

  const PrimaryButton({
    super.key,
    this.icon,
    required this.onTap,
    required this.text,
    this.color = Colors.blue,
    this.width = 392,
    this.height = 64,
    this.fontSize = 16,
    this.spaceBetweenIconAndText = 8,
    this.borderRadius = 12,

    // Add default color
  });

  @override
  Widget build(BuildContext context) {
    return InkWell(
      onTap: onTap,
      child: Container(
        width: width,
        height: height,
        decoration: ShapeDecoration(
          color: color,
          shape: RoundedRectangleBorder(
            borderRadius: BorderRadius.circular(borderRadius),
          ),
        ),
        child: Center(
          child: Row(
            // Use Row for icon and text
            mainAxisAlignment: MainAxisAlignment.center,
            children: [
              if (icon != null) ...[
                icon!,
                SizedBox(
                    width:
                        spaceBetweenIconAndText), // Add spacing between icon and text
              ],
              Text(
                text,
                style: TextStyle(
                  color: Colors.white,
                  fontSize: fontSize,
                  letterSpacing: 0.5,
                  fontFamily: GoogleFonts.montserrat().fontFamily,
                  fontWeight: FontWeight.bold,
                ),
              ),
            ],
          ),
        ),
      ),
    );
  }
}
Updated on