1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980 |
- import 'package:flutter/material.dart';
- import 'package:get/get.dart';
- import 'package:ftrecruiter/comm/constants/color_constants.dart';
- import 'package:ftrecruiter/comm/utils/dark_theme_util.dart';
- class MyButton extends StatelessWidget {
- const MyButton({
- Key? key,
- this.text = '',
- this.fontSize = 16,
- this.textColor,
- this.disabledTextColor,
- this.backgroundColor,
- this.disabledBackgroundColor,
- this.minHeight = 48.0,
- this.minWidth = double.infinity,
- this.padding = const EdgeInsets.symmetric(horizontal: 16.0),
- this.radius = 5.0,
- this.side = BorderSide.none,
- required this.onPressed,
- }) : super(key: key);
- final String text;
- final double fontSize;
- final Color? textColor;
- final Color? disabledTextColor;
- final Color? backgroundColor;
- final Color? disabledBackgroundColor;
- final double? minHeight;
- final double? minWidth;
- final VoidCallback? onPressed;
- final EdgeInsetsGeometry padding;
- final double radius;
- final BorderSide side;
- @override
- Widget build(BuildContext context) {
- return TextButton(
- onPressed: onPressed,
- style: ButtonStyle(
-
- foregroundColor: MaterialStateProperty.resolveWith(
- (states) {
- if (states.contains(MaterialState.disabled)) {
- return DarkThemeUtil.multiColors(disabledTextColor ?? Colors.grey, darkColor: Colors.grey);
- }
- return DarkThemeUtil.multiColors(textColor ?? Colors.white,darkColor: Colors.white);
- },
- ),
-
- backgroundColor: MaterialStateProperty.resolveWith((states) {
- if (states.contains(MaterialState.disabled)) {
- return DarkThemeUtil.multiColors(disabledBackgroundColor ?? Colors.white,darkColor: Colors.lightBlue);
- }
- return DarkThemeUtil.multiColors(backgroundColor ?? Colors.white,darkColor: ColorConstants.appBlue);
- }),
-
- overlayColor: MaterialStateProperty.resolveWith((states) {
- return DarkThemeUtil.multiColors(textColor ?? Colors.white).withOpacity(0.12);
- }),
-
- minimumSize: (minWidth == null || minHeight == null)
- ? null
- : MaterialStateProperty.all<Size>(Size(minWidth!, minHeight!)),
- padding: MaterialStateProperty.all<EdgeInsetsGeometry>(padding),
- shape: MaterialStateProperty.all<OutlinedBorder>(
- RoundedRectangleBorder(
- borderRadius: BorderRadius.circular(radius),
- ),
- ),
- side: MaterialStateProperty.all<BorderSide>(side),
- ),
- child: Text(
- text,
- style: TextStyle(fontSize: fontSize),
- ));
- }
- }
|