|
- import 'package:flutter/material.dart';
- import '../../../themes/app_dimension.dart';
- import '../../../themes/app_colors.dart';
- import '../../../themes/styles_text.dart';
-
- class PrimaryButtonWidget extends StatelessWidget {
- final String title;
- final double width;
- final double? height;
- final bool isEnable;
- final VoidCallback? onPressed;
- final Color? color;
- final Color? titleColor;
-
- const PrimaryButtonWidget({
- required this.title,
- this.onPressed,
- this.width = double.infinity,
- this.isEnable = true,
- this.color,
- this.height,
- this.titleColor,
- });
-
- @override
- Widget build(BuildContext context) {
- return SizedBox(
- width: width,
- height: height ?? 45.h,
- child: ElevatedButton(
- onPressed: isEnable ? onPressed : null,
- style: ButtonStyle(
- backgroundColor: MaterialStateProperty.resolveWith(
- (states) {
- if (states.contains(MaterialState.disabled)) {
- return AppColors.neutral4;
- }
- return color ?? AppColors.primary1;
- },
- ),
- shadowColor: MaterialStateProperty.resolveWith(
- (states) {
- return Colors.transparent;
- },
- ),
- overlayColor: MaterialStateProperty.resolveWith(
- (states) {
- return Colors.transparent;
- },
- ),
- shape: MaterialStateProperty.all<RoundedRectangleBorder>(
- RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(12.0),
- ),
- ),
- ),
- child: Text(
- title,
- style: StylesText.body5.copyWith(
- color: titleColor ?? AppColors.white,
- ),
- ),
- ),
- );
- }
- }
|