diff --git a/packages/flutter/lib/src/material/icon_button.dart b/packages/flutter/lib/src/material/icon_button.dart index 29c51c3cd6..aa0a68b073 100644 --- a/packages/flutter/lib/src/material/icon_button.dart +++ b/packages/flutter/lib/src/material/icon_button.dart @@ -2,6 +2,8 @@ // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. +import 'dart:math' as math; + import 'package:flutter/widgets.dart'; import 'package:meta/meta.dart'; @@ -126,7 +128,7 @@ class IconButton extends StatelessWidget { maxHeight: size, child: new ConstrainedBox( constraints: new BoxConstraints.loose( - const Size.square(InkSplash.defaultRadius * 2.0) + new Size.square(math.max(size, InkSplash.defaultRadius * 2.0)) ), child: new Align( alignment: alignment, @@ -150,7 +152,8 @@ class IconButton extends StatelessWidget { } return new InkResponse( onTap: onPressed, - child: result + child: result, + radius: math.max(size, InkSplash.defaultRadius), ); } diff --git a/packages/flutter/lib/src/material/ink_well.dart b/packages/flutter/lib/src/material/ink_well.dart index af6ac6eb31..04aa20d951 100644 --- a/packages/flutter/lib/src/material/ink_well.dart +++ b/packages/flutter/lib/src/material/ink_well.dart @@ -36,7 +36,8 @@ class InkResponse extends StatefulWidget { this.onLongPress, this.onHighlightChanged, this.containedInkWell: false, - this.highlightShape: BoxShape.circle + this.highlightShape: BoxShape.circle, + this.radius, }) : super(key: key); /// The widget below this widget in the tree. @@ -64,6 +65,9 @@ class InkResponse extends StatefulWidget { /// The shape (e.g., circle, rectangle) to use for the highlight drawn around this part of the material. final BoxShape highlightShape; + /// The radius of the ink splash. + final double radius; + /// The rectangle to use for the highlight effect and for clipping /// the splash effects if [containedInkWell] is true. /// @@ -138,6 +142,7 @@ class _InkResponseState extends State { color: Theme.of(context).splashColor, containedInkWell: config.containedInkWell, rectCallback: config.containedInkWell ? rectCallback : null, + radius: config.radius, onRemoved: () { if (_splashes != null) { assert(_splashes.contains(splash)); diff --git a/packages/flutter/lib/src/material/material.dart b/packages/flutter/lib/src/material/material.dart index a5cb73429c..aea80ff7e7 100644 --- a/packages/flutter/lib/src/material/material.dart +++ b/packages/flutter/lib/src/material/material.dart @@ -121,7 +121,8 @@ abstract class MaterialInkController { Color color, bool containedInkWell: false, RectCallback rectCallback, - VoidCallback onRemoved + VoidCallback onRemoved, + double radius, }); /// Begin a highlight animation. If a rectCallback is given, then it @@ -321,9 +322,9 @@ class _RenderInkFeatures extends RenderProxyBox implements MaterialInkController Color color, bool containedInkWell: false, RectCallback rectCallback, - VoidCallback onRemoved + VoidCallback onRemoved, + double radius, }) { - double radius; RectCallback clipCallback; if (containedInkWell) { Size size; @@ -334,10 +335,10 @@ class _RenderInkFeatures extends RenderProxyBox implements MaterialInkController size = referenceBox.size; clipCallback = () => Point.origin & referenceBox.size; } - radius = _getSplashTargetSize(size, position); + radius ??= _getSplashTargetSize(size, position); } else { assert(rectCallback == null); - radius = InkSplash.defaultRadius; + radius ??= InkSplash.defaultRadius; } _InkSplash splash = new _InkSplash( controller: this, diff --git a/packages/flutter/test/material/icon_button_test.dart b/packages/flutter/test/material/icon_button_test.dart index bb3e8276a3..24cf7ff30b 100644 --- a/packages/flutter/test/material/icon_button_test.dart +++ b/packages/flutter/test/material/icon_button_test.dart @@ -7,21 +7,24 @@ import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('IconButton test constrained size', (WidgetTester tester) async { + const double kIconSize = 80.0; + await tester.pumpWidget( new Material( child: new Center( child: new IconButton( padding: EdgeInsets.zero, onPressed: () {}, - icon: new Icon(Icons.ac_unit) + icon: new Icon(Icons.ac_unit), + size: kIconSize, ) ) ) ); RenderBox box = tester.renderObject(find.byType(IconButton)); - expect(box.size.width, equals(InkSplash.defaultRadius * 2.0)); - expect(box.size.height, equals(InkSplash.defaultRadius * 2.0)); + expect(box.size.width, equals(kIconSize)); + expect(box.size.height, equals(kIconSize)); }); testWidgets('IconButton AppBar size', (WidgetTester tester) async { @@ -32,7 +35,7 @@ void main() { new IconButton( padding: EdgeInsets.zero, onPressed: () {}, - icon: new Icon(Icons.ac_unit) + icon: new Icon(Icons.ac_unit), ) ] )