File tree 4 files changed +24
-12
lines changed
4 files changed +24
-12
lines changed Original file line number Diff line number Diff line change 2
2
// Use of this source code is governed by a BSD-style license that can be
3
3
// found in the LICENSE file.
4
4
5
+ import 'dart:math' as math;
6
+
5
7
import 'package:flutter/widgets.dart' ;
6
8
import 'package:meta/meta.dart' ;
7
9
@@ -126,7 +128,7 @@ class IconButton extends StatelessWidget {
126
128
maxHeight: size,
127
129
child: new ConstrainedBox (
128
130
constraints: new BoxConstraints .loose (
129
- const Size .square (InkSplash .defaultRadius * 2.0 )
131
+ new Size .square (math. max (size, InkSplash .defaultRadius * 2.0 ) )
130
132
),
131
133
child: new Align (
132
134
alignment: alignment,
@@ -150,7 +152,8 @@ class IconButton extends StatelessWidget {
150
152
}
151
153
return new InkResponse (
152
154
onTap: onPressed,
153
- child: result
155
+ child: result,
156
+ radius: math.max (size, InkSplash .defaultRadius),
154
157
);
155
158
}
156
159
Original file line number Diff line number Diff line change @@ -36,7 +36,8 @@ class InkResponse extends StatefulWidget {
36
36
this .onLongPress,
37
37
this .onHighlightChanged,
38
38
this .containedInkWell: false ,
39
- this .highlightShape: BoxShape .circle
39
+ this .highlightShape: BoxShape .circle,
40
+ this .radius,
40
41
}) : super (key: key);
41
42
42
43
/// The widget below this widget in the tree.
@@ -64,6 +65,9 @@ class InkResponse extends StatefulWidget {
64
65
/// The shape (e.g., circle, rectangle) to use for the highlight drawn around this part of the material.
65
66
final BoxShape highlightShape;
66
67
68
+ /// The radius of the ink splash.
69
+ final double radius;
70
+
67
71
/// The rectangle to use for the highlight effect and for clipping
68
72
/// the splash effects if [containedInkWell] is true.
69
73
///
@@ -138,6 +142,7 @@ class _InkResponseState<T extends InkResponse> extends State<T> {
138
142
color: Theme .of (context).splashColor,
139
143
containedInkWell: config.containedInkWell,
140
144
rectCallback: config.containedInkWell ? rectCallback : null ,
145
+ radius: config.radius,
141
146
onRemoved: () {
142
147
if (_splashes != null ) {
143
148
assert (_splashes.contains (splash));
Original file line number Diff line number Diff line change @@ -121,7 +121,8 @@ abstract class MaterialInkController {
121
121
Color color,
122
122
bool containedInkWell: false ,
123
123
RectCallback rectCallback,
124
- VoidCallback onRemoved
124
+ VoidCallback onRemoved,
125
+ double radius,
125
126
});
126
127
127
128
/// Begin a highlight animation. If a rectCallback is given, then it
@@ -321,9 +322,9 @@ class _RenderInkFeatures extends RenderProxyBox implements MaterialInkController
321
322
Color color,
322
323
bool containedInkWell: false ,
323
324
RectCallback rectCallback,
324
- VoidCallback onRemoved
325
+ VoidCallback onRemoved,
326
+ double radius,
325
327
}) {
326
- double radius;
327
328
RectCallback clipCallback;
328
329
if (containedInkWell) {
329
330
Size size;
@@ -334,10 +335,10 @@ class _RenderInkFeatures extends RenderProxyBox implements MaterialInkController
334
335
size = referenceBox.size;
335
336
clipCallback = () => Point .origin & referenceBox.size;
336
337
}
337
- radius = _getSplashTargetSize (size, position);
338
+ radius ?? = _getSplashTargetSize (size, position);
338
339
} else {
339
340
assert (rectCallback == null );
340
- radius = InkSplash .defaultRadius;
341
+ radius ?? = InkSplash .defaultRadius;
341
342
}
342
343
_InkSplash splash = new _InkSplash (
343
344
controller: this ,
Original file line number Diff line number Diff line change @@ -7,21 +7,24 @@ import 'package:flutter_test/flutter_test.dart';
7
7
8
8
void main () {
9
9
testWidgets ('IconButton test constrained size' , (WidgetTester tester) async {
10
+ const double kIconSize = 80.0 ;
11
+
10
12
await tester.pumpWidget (
11
13
new Material (
12
14
child: new Center (
13
15
child: new IconButton (
14
16
padding: EdgeInsets .zero,
15
17
onPressed: () {},
16
- icon: new Icon (Icons .ac_unit)
18
+ icon: new Icon (Icons .ac_unit),
19
+ size: kIconSize,
17
20
)
18
21
)
19
22
)
20
23
);
21
24
22
25
RenderBox box = tester.renderObject (find.byType (IconButton ));
23
- expect (box.size.width, equals (InkSplash .defaultRadius * 2.0 ));
24
- expect (box.size.height, equals (InkSplash .defaultRadius * 2.0 ));
26
+ expect (box.size.width, equals (kIconSize ));
27
+ expect (box.size.height, equals (kIconSize ));
25
28
});
26
29
27
30
testWidgets ('IconButton AppBar size' , (WidgetTester tester) async {
@@ -32,7 +35,7 @@ void main() {
32
35
new IconButton (
33
36
padding: EdgeInsets .zero,
34
37
onPressed: () {},
35
- icon: new Icon (Icons .ac_unit)
38
+ icon: new Icon (Icons .ac_unit),
36
39
)
37
40
]
38
41
)
You can’t perform that action at this time.
0 commit comments