costum1 method

Widget costum1({
  1. required String text,
  2. required Function onPressed,
  3. required bool loadingStatus,
  4. Color? background,
  5. bool enabled = true,
})

Implementation

Widget costum1({
  required String text,
  required Function onPressed,
  required bool loadingStatus,
  Color? background,
  bool enabled = true,
}) {
  Color foregroundColor = Colors.white;

  return loadingStatus
      ? const CupertinoActivityIndicator()
      : ElevatedButton(
          onPressed: !enabled
              ? null
              : () async {
                  if (!loadingStatus) {
                    await onPressed();
                  }
                },
          style: ElevatedButton.styleFrom(
            backgroundColor: background,
            foregroundColor: foregroundColor,
            padding: const EdgeInsets.symmetric(vertical: 12, horizontal: 18),
            shape: RoundedRectangleBorder(
              borderRadius: BorderRadius.circular(10),
            ),
          ),
          child: Text(
            text,
            style: TextStyle(
              fontWeight: FontWeight.bold,
              fontSize: 16,
              color:
                  !enabled ? const Color.fromARGB(255, 211, 211, 211) : null,
            ),
          ),
        );
}