showSnackBar function

void showSnackBar({
  1. String title = "",
  2. bool isSuccess = false,
  3. SnackBarAction? action,
  4. int seconds = 1,
  5. required BuildContext context,
})

Implementation

void showSnackBar({String title = "", bool isSuccess = false, SnackBarAction? action, int seconds = 1,required BuildContext context}) {
  WidgetsBinding.instance.addPostFrameCallback((_) {
    removeCurrentSnackBar(context);
    ScaffoldMessenger.of(context).showSnackBar(
      SnackBar(
        behavior: SnackBarBehavior.fixed,
        backgroundColor: isSuccess
            ? ColorConstants.successBgSnackBarColor
            : ColorConstants.errorBgSnackBarColor,
        duration: Duration(seconds: seconds),
        content: Text(
          title,
          style: TextStyle(
            color: isSuccess
                ? ColorConstants.successTextSnackBarColor
                : ColorConstants.errorTextSnackBarColor,
            fontSize: 13,
            fontWeight: FontWeight.w500,
            overflow: TextOverflow.ellipsis,
          ),
          maxLines: 10,
        ),
        action: action,
      ),
    );
    });
}