Expose clipBehavior to more buttons (#20538)
This allows developers to control the clipBehavior of those buttons.
This commit is contained in:
parent
fd44d0bb65
commit
5d6707b78e
@ -38,6 +38,8 @@ import 'theme_data.dart';
|
|||||||
/// Flat buttons have a minimum size of 88.0 by 36.0 which can be overidden
|
/// Flat buttons have a minimum size of 88.0 by 36.0 which can be overidden
|
||||||
/// with [ButtonTheme].
|
/// with [ButtonTheme].
|
||||||
///
|
///
|
||||||
|
/// The [clipBehavior] argument must not be null.
|
||||||
|
///
|
||||||
/// See also:
|
/// See also:
|
||||||
///
|
///
|
||||||
/// * [RaisedButton], a filled button whose material elevates when pressed.
|
/// * [RaisedButton], a filled button whose material elevates when pressed.
|
||||||
@ -63,9 +65,10 @@ class FlatButton extends StatelessWidget {
|
|||||||
this.colorBrightness,
|
this.colorBrightness,
|
||||||
this.padding,
|
this.padding,
|
||||||
this.shape,
|
this.shape,
|
||||||
|
this.clipBehavior = Clip.none,
|
||||||
this.materialTapTargetSize,
|
this.materialTapTargetSize,
|
||||||
@required this.child,
|
@required this.child,
|
||||||
}) : super(key: key);
|
}) : assert(clipBehavior != null), super(key: key);
|
||||||
|
|
||||||
/// Create a text button from a pair of widgets that serve as the button's
|
/// Create a text button from a pair of widgets that serve as the button's
|
||||||
/// [icon] and [label].
|
/// [icon] and [label].
|
||||||
@ -73,7 +76,7 @@ class FlatButton extends StatelessWidget {
|
|||||||
/// The icon and label are arranged in a row and padded by 12 logical pixels
|
/// The icon and label are arranged in a row and padded by 12 logical pixels
|
||||||
/// at the start, and 16 at the end, with an 8 pixel gap in between.
|
/// at the start, and 16 at the end, with an 8 pixel gap in between.
|
||||||
///
|
///
|
||||||
/// The [icon] and [label] arguments must not be null.
|
/// The [icon], [label], and [clipBehavior] arguments must not be null.
|
||||||
FlatButton.icon({
|
FlatButton.icon({
|
||||||
Key key,
|
Key key,
|
||||||
@required this.onPressed,
|
@required this.onPressed,
|
||||||
@ -87,11 +90,13 @@ class FlatButton extends StatelessWidget {
|
|||||||
this.splashColor,
|
this.splashColor,
|
||||||
this.colorBrightness,
|
this.colorBrightness,
|
||||||
this.shape,
|
this.shape,
|
||||||
|
this.clipBehavior = Clip.none,
|
||||||
this.materialTapTargetSize,
|
this.materialTapTargetSize,
|
||||||
@required Widget icon,
|
@required Widget icon,
|
||||||
@required Widget label,
|
@required Widget label,
|
||||||
}) : assert(icon != null),
|
}) : assert(icon != null),
|
||||||
assert(label != null),
|
assert(label != null),
|
||||||
|
assert(clipBehavior != null),
|
||||||
padding = const EdgeInsetsDirectional.only(start: 12.0, end: 16.0),
|
padding = const EdgeInsetsDirectional.only(start: 12.0, end: 16.0),
|
||||||
child = new Row(
|
child = new Row(
|
||||||
mainAxisSize: MainAxisSize.min,
|
mainAxisSize: MainAxisSize.min,
|
||||||
@ -221,6 +226,9 @@ class FlatButton extends StatelessWidget {
|
|||||||
/// shape as well.
|
/// shape as well.
|
||||||
final ShapeBorder shape;
|
final ShapeBorder shape;
|
||||||
|
|
||||||
|
/// {@macro flutter.widgets.Clip}
|
||||||
|
final Clip clipBehavior;
|
||||||
|
|
||||||
Brightness _getBrightness(ThemeData theme) {
|
Brightness _getBrightness(ThemeData theme) {
|
||||||
return colorBrightness ?? theme.brightness;
|
return colorBrightness ?? theme.brightness;
|
||||||
}
|
}
|
||||||
@ -306,6 +314,7 @@ class FlatButton extends StatelessWidget {
|
|||||||
padding: padding ?? buttonTheme.padding,
|
padding: padding ?? buttonTheme.padding,
|
||||||
constraints: buttonTheme.constraints,
|
constraints: buttonTheme.constraints,
|
||||||
shape: shape ?? buttonTheme.shape,
|
shape: shape ?? buttonTheme.shape,
|
||||||
|
clipBehavior: clipBehavior,
|
||||||
child: child,
|
child: child,
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,7 @@ class _DefaultHeroTag {
|
|||||||
class FloatingActionButton extends StatefulWidget {
|
class FloatingActionButton extends StatefulWidget {
|
||||||
/// Creates a circular floating action button.
|
/// Creates a circular floating action button.
|
||||||
///
|
///
|
||||||
/// The [elevation], [highlightElevation], [mini], and [shape]
|
/// The [elevation], [highlightElevation], [mini], [shape], and [clipBehavior]
|
||||||
/// arguments must not be null.
|
/// arguments must not be null.
|
||||||
const FloatingActionButton({
|
const FloatingActionButton({
|
||||||
Key key,
|
Key key,
|
||||||
@ -71,6 +71,7 @@ class FloatingActionButton extends StatefulWidget {
|
|||||||
@required this.onPressed,
|
@required this.onPressed,
|
||||||
this.mini = false,
|
this.mini = false,
|
||||||
this.shape = const CircleBorder(),
|
this.shape = const CircleBorder(),
|
||||||
|
this.clipBehavior = Clip.none,
|
||||||
this.materialTapTargetSize,
|
this.materialTapTargetSize,
|
||||||
this.isExtended = false,
|
this.isExtended = false,
|
||||||
}) : assert(elevation != null),
|
}) : assert(elevation != null),
|
||||||
@ -84,7 +85,7 @@ class FloatingActionButton extends StatefulWidget {
|
|||||||
/// Creates a wider [StadiumBorder] shaped floating action button with both
|
/// Creates a wider [StadiumBorder] shaped floating action button with both
|
||||||
/// an [icon] and a [label].
|
/// an [icon] and a [label].
|
||||||
///
|
///
|
||||||
/// The [label], [icon], [elevation], [highlightElevation]
|
/// The [label], [icon], [elevation], [highlightElevation], [clipBehavior]
|
||||||
/// and [shape] arguments must not be null.
|
/// and [shape] arguments must not be null.
|
||||||
FloatingActionButton.extended({
|
FloatingActionButton.extended({
|
||||||
Key key,
|
Key key,
|
||||||
@ -98,12 +99,14 @@ class FloatingActionButton extends StatefulWidget {
|
|||||||
this.shape = const StadiumBorder(),
|
this.shape = const StadiumBorder(),
|
||||||
this.isExtended = true,
|
this.isExtended = true,
|
||||||
this.materialTapTargetSize,
|
this.materialTapTargetSize,
|
||||||
|
this.clipBehavior = Clip.none,
|
||||||
@required Widget icon,
|
@required Widget icon,
|
||||||
@required Widget label,
|
@required Widget label,
|
||||||
}) : assert(elevation != null),
|
}) : assert(elevation != null),
|
||||||
assert(highlightElevation != null),
|
assert(highlightElevation != null),
|
||||||
assert(shape != null),
|
assert(shape != null),
|
||||||
assert(isExtended != null),
|
assert(isExtended != null),
|
||||||
|
assert(clipBehavior != null),
|
||||||
_sizeConstraints = _kExtendedSizeConstraints,
|
_sizeConstraints = _kExtendedSizeConstraints,
|
||||||
mini = false,
|
mini = false,
|
||||||
child = new _ChildOverflowBox(
|
child = new _ChildOverflowBox(
|
||||||
@ -193,6 +196,9 @@ class FloatingActionButton extends StatefulWidget {
|
|||||||
/// shape as well.
|
/// shape as well.
|
||||||
final ShapeBorder shape;
|
final ShapeBorder shape;
|
||||||
|
|
||||||
|
/// {@macro flutter.widgets.Clip}
|
||||||
|
final Clip clipBehavior;
|
||||||
|
|
||||||
/// True if this is an "extended" floating action button.
|
/// True if this is an "extended" floating action button.
|
||||||
///
|
///
|
||||||
/// Typically [extended] buttons have a [StadiumBorder] [shape]
|
/// Typically [extended] buttons have a [StadiumBorder] [shape]
|
||||||
@ -265,6 +271,7 @@ class _FloatingActionButtonState extends State<FloatingActionButton> {
|
|||||||
letterSpacing: 1.2,
|
letterSpacing: 1.2,
|
||||||
),
|
),
|
||||||
shape: widget.shape,
|
shape: widget.shape,
|
||||||
|
clipBehavior: widget.clipBehavior,
|
||||||
child: result,
|
child: result,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user