Loading files
import 'package:flutter/material.dart';
extension FilledButtonDanger on FilledButton {
static FilledButton danger({
required BuildContext context,
required VoidCallback? onPressed,
VoidCallback? onLongPress,
ValueChanged<bool>? onHover,
ValueChanged<bool>? onFocusChange,
ButtonStyle? style,
FocusNode? focusNode,
bool autofocus = false,
Clip clipBehavior = Clip.none,
required Widget child,
}) {
final theme = Theme.of(context);
final destructiveStyle = FilledButton.styleFrom(
backgroundColor: theme.colorScheme.error,
foregroundColor: theme.colorScheme.onError,
).merge(style);
return FilledButton(
onPressed: onPressed,
onLongPress: onLongPress,
onHover: onHover,
onFocusChange: onFocusChange,
style: destructiveStyle,
focusNode: focusNode,
autofocus: autofocus,
clipBehavior: clipBehavior,
child: child,
);
}
static FilledButton tonalDanger({
required BuildContext context,
required VoidCallback? onPressed,
required Widget child,
}) {
final theme = Theme.of(context);
return FilledButton.tonal(
onPressed: onPressed,
style: FilledButton.styleFrom(
backgroundColor: theme.colorScheme.errorContainer,
foregroundColor: theme.colorScheme.onErrorContainer,
),
child: child,
);
}
}
16d810192This file is pinned to the selected release. Download the original to open it in your design tool.