show<T> static method

dynamic show<T>(
  1. BuildContext context, {
  2. required DigitToastOptions options,
})

Implementation

static show<T>(
  BuildContext context, {
  required DigitToastOptions options,
}) {
  ftoast.init(context);

  final theme = Theme.of(context);

  return ftoast.showToast(
    child: Container(
      color: options.isError
          ? options.theme.colorScheme.error
          : options.theme.colorScheme.onSurfaceVariant,
      padding:
          const EdgeInsets.symmetric(horizontal: kPadding, vertical: 12.0),
      child: Row(
        mainAxisSize: MainAxisSize.min,
        children: [
          Icon(
            options.isError ? Icons.info_outline_rounded : Icons.check,
            color: Colors.white,
          ),
          const SizedBox(
            width: kPadding * 2,
          ),
          Expanded(
            child: Text(
              options.message,
              style: TextStyle(
                fontSize: theme.textTheme.bodyLarge?.fontSize,
                fontWeight: theme.textTheme.bodyLarge?.fontWeight,
                color: const DigitColors().white,
              ),
            ),
          ),
          GestureDetector(
            onTap: () {
              ftoast.removeCustomToast();
            },
            child: Icon(
              Icons.close,
              color: const DigitColors().white,
            ),
          ),
        ],
      ),
    ),
    gravity: ToastGravity.SNACKBAR,
    toastDuration: DigitTheme.instance.toastDuration,
  );
}