outlineButtonStyle function

ButtonStyle outlineButtonStyle(
  1. ColorScheme colorScheme, {
  2. Color? primary,
  3. Color? onSurface,
  4. Color? backgroundColor,
  5. Color? shadowColor,
  6. Color? splashColor,
  7. double? elevation,
  8. TextStyle? textStyle,
  9. EdgeInsetsGeometry? padding,
  10. Size? minimumSize,
  11. Size? fixedSize,
  12. Size? maximumSize,
  13. BorderSide? side,
  14. OutlinedBorder? shape,
  15. MouseCursor? enabledMouseCursor,
  16. MouseCursor? disabledMouseCursor,
  17. VisualDensity? visualDensity,
  18. MaterialTapTargetSize? tapTargetSize,
  19. Duration? animationDuration,
  20. bool? enableFeedback,
  21. AlignmentGeometry? alignment,
  22. InteractiveInkFeatureFactory? splashFactory,
})

Returns a ButtonStyle that is used to make a OutlinedButton look like a deprecated OutlineButton, but with given styles.

Implementation

ButtonStyle outlineButtonStyle(
  ColorScheme colorScheme, {
  Color? primary,
  Color? onSurface,
  Color? backgroundColor,
  Color? shadowColor,
  Color? splashColor,
  double? elevation,
  TextStyle? textStyle,
  EdgeInsetsGeometry? padding,
  Size? minimumSize,
  Size? fixedSize,
  Size? maximumSize,
  BorderSide? side,
  OutlinedBorder? shape,
  MouseCursor? enabledMouseCursor,
  MouseCursor? disabledMouseCursor,
  VisualDensity? visualDensity,
  MaterialTapTargetSize? tapTargetSize,
  Duration? animationDuration,
  bool? enableFeedback,
  AlignmentGeometry? alignment,
  InteractiveInkFeatureFactory? splashFactory,
}) {
  var style = OutlinedButton.styleFrom(
    // fields for OutlineButton
    primary: primary ?? Colors.black87,
    padding: padding ?? const EdgeInsets.symmetric(horizontal: 16.0),
    shape: shape ?? const RoundedRectangleBorder(borderRadius: BorderRadius.all(Radius.circular(2.0))),
    // fields for OutlinedButton
    onSurface: onSurface,
    backgroundColor: backgroundColor,
    shadowColor: shadowColor,
    elevation: elevation,
    textStyle: textStyle,
    minimumSize: minimumSize,
    fixedSize: fixedSize,
    maximumSize: maximumSize,
    side: side,
    enabledMouseCursor: enabledMouseCursor,
    disabledMouseCursor: disabledMouseCursor,
    visualDensity: visualDensity,
    tapTargetSize: tapTargetSize,
    animationDuration: animationDuration,
    enableFeedback: enableFeedback,
    alignment: alignment,
    splashFactory: splashFactory,
  );
  if (splashColor != null) {
    // add extra splashColor style
    style = style.copyWith(
      overlayColor: MaterialStateProperty.resolveWith(
        (s) => s.contains(MaterialState.pressed) ? splashColor : null,
      ),
    );
  }
  if (side == null) {
    // use default side style
    style = style.copyWith(
      side: MaterialStateProperty.resolveWith<BorderSide?>(
        (Set<MaterialState> states) {
          if (states.contains(MaterialState.pressed)) {
            return BorderSide(
              color: colorScheme.primary,
              width: 1,
            );
          }
          return null; // Defer to the widget's default.
        },
      ),
    );
  }
  return style;
}