GradientTextButton constructor

GradientTextButton({
  1. Key? key,
  2. required VoidCallback? onPressed,
  3. Color? splashColor,
  4. VoidCallback? onLongPress,
  5. ButtonStyle? style,
  6. FocusNode? focusNode,
  7. bool autofocus = false,
  8. Clip clipBehavior = Clip.none,
  9. required Gradient gradient,
  10. required Widget child,
  11. EdgeInsetsGeometry padding = const EdgeInsets.all(8),
})

Create a TextButton.

The autofocus and clipBehavior arguments must not be null.

Implementation

GradientTextButton({
  Key? key,
  required VoidCallback? onPressed,
  Color? splashColor,
  VoidCallback? onLongPress,
  ButtonStyle? style,
  FocusNode? focusNode,
  bool autofocus = false,
  Clip clipBehavior = Clip.none,
  required Gradient gradient,
  required Widget child,
  EdgeInsetsGeometry padding = const EdgeInsets.all(8),
}) : super(
        key: key,
        onPressed: onPressed,
        onLongPress: onLongPress,
        style: style ??
            ButtonStyle(
                overlayColor: ButtonStyleButton.allOrNull(splashColor ??
                    gradient.colors.elementAt(0).withOpacity(0.1))),
        focusNode: focusNode,
        autofocus: autofocus,
        clipBehavior: clipBehavior,
        child: Padding(
          padding: style?.padding != null ? EdgeInsets.zero : padding,
          child: ShaderMask(
            shaderCallback: (Rect bounds) => gradient.createShader(
              Rect.fromLTWH(0, 0, bounds.width, bounds.height),
            ),
            blendMode: BlendMode.srcIn,
            child: child,
          ),
        ),
      );