Unverified Commit 5d6707b7 authored by liyuqian's avatar liyuqian Committed by GitHub

Expose clipBehavior to more buttons (#20538)

This allows developers to control the clipBehavior of those buttons.
parent fd44d0bb
......@@ -38,6 +38,8 @@ import 'theme_data.dart';
/// Flat buttons have a minimum size of 88.0 by 36.0 which can be overidden
/// with [ButtonTheme].
///
/// The [clipBehavior] argument must not be null.
///
/// See also:
///
/// * [RaisedButton], a filled button whose material elevates when pressed.
......@@ -63,9 +65,10 @@ class FlatButton extends StatelessWidget {
this.colorBrightness,
this.padding,
this.shape,
this.clipBehavior = Clip.none,
this.materialTapTargetSize,
@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
/// [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
/// 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({
Key key,
@required this.onPressed,
......@@ -87,11 +90,13 @@ class FlatButton extends StatelessWidget {
this.splashColor,
this.colorBrightness,
this.shape,
this.clipBehavior = Clip.none,
this.materialTapTargetSize,
@required Widget icon,
@required Widget label,
}) : assert(icon != null),
assert(label != null),
assert(clipBehavior != null),
padding = const EdgeInsetsDirectional.only(start: 12.0, end: 16.0),
child = new Row(
mainAxisSize: MainAxisSize.min,
......@@ -221,6 +226,9 @@ class FlatButton extends StatelessWidget {
/// shape as well.
final ShapeBorder shape;
/// {@macro flutter.widgets.Clip}
final Clip clipBehavior;
Brightness _getBrightness(ThemeData theme) {
return colorBrightness ?? theme.brightness;
}
......@@ -306,6 +314,7 @@ class FlatButton extends StatelessWidget {
padding: padding ?? buttonTheme.padding,
constraints: buttonTheme.constraints,
shape: shape ?? buttonTheme.shape,
clipBehavior: clipBehavior,
child: child,
);
}
......
......@@ -57,7 +57,7 @@ class _DefaultHeroTag {
class FloatingActionButton extends StatefulWidget {
/// Creates a circular floating action button.
///
/// The [elevation], [highlightElevation], [mini], and [shape]
/// The [elevation], [highlightElevation], [mini], [shape], and [clipBehavior]
/// arguments must not be null.
const FloatingActionButton({
Key key,
......@@ -71,6 +71,7 @@ class FloatingActionButton extends StatefulWidget {
@required this.onPressed,
this.mini = false,
this.shape = const CircleBorder(),
this.clipBehavior = Clip.none,
this.materialTapTargetSize,
this.isExtended = false,
}) : assert(elevation != null),
......@@ -84,7 +85,7 @@ class FloatingActionButton extends StatefulWidget {
/// Creates a wider [StadiumBorder] shaped floating action button with both
/// an [icon] and a [label].
///
/// The [label], [icon], [elevation], [highlightElevation]
/// The [label], [icon], [elevation], [highlightElevation], [clipBehavior]
/// and [shape] arguments must not be null.
FloatingActionButton.extended({
Key key,
......@@ -98,12 +99,14 @@ class FloatingActionButton extends StatefulWidget {
this.shape = const StadiumBorder(),
this.isExtended = true,
this.materialTapTargetSize,
this.clipBehavior = Clip.none,
@required Widget icon,
@required Widget label,
}) : assert(elevation != null),
assert(highlightElevation != null),
assert(shape != null),
assert(isExtended != null),
assert(clipBehavior != null),
_sizeConstraints = _kExtendedSizeConstraints,
mini = false,
child = new _ChildOverflowBox(
......@@ -193,6 +196,9 @@ class FloatingActionButton extends StatefulWidget {
/// shape as well.
final ShapeBorder shape;
/// {@macro flutter.widgets.Clip}
final Clip clipBehavior;
/// True if this is an "extended" floating action button.
///
/// Typically [extended] buttons have a [StadiumBorder] [shape]
......@@ -265,6 +271,7 @@ class _FloatingActionButtonState extends State<FloatingActionButton> {
letterSpacing: 1.2,
),
shape: widget.shape,
clipBehavior: widget.clipBehavior,
child: result,
);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment