Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Sign in
Toggle navigation
F
Front-End
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
abdullh.alsoleman
Front-End
Commits
90504b12
Commit
90504b12
authored
Oct 06, 2016
by
Jason Simmons
Committed by
GitHub
Oct 06, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Adjust the IconButton constraint to match its size (#6226)
Fixes
https://github.com/flutter/flutter/issues/5763
parent
3c40c855
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
24 additions
and
12 deletions
+24
-12
icon_button.dart
packages/flutter/lib/src/material/icon_button.dart
+5
-2
ink_well.dart
packages/flutter/lib/src/material/ink_well.dart
+6
-1
material.dart
packages/flutter/lib/src/material/material.dart
+6
-5
icon_button_test.dart
packages/flutter/test/material/icon_button_test.dart
+7
-4
No files found.
packages/flutter/lib/src/material/icon_button.dart
View file @
90504b12
...
...
@@ -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
),
);
}
...
...
packages/flutter/lib/src/material/ink_well.dart
View file @
90504b12
...
...
@@ -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<T extends InkResponse> extends State<T> {
color:
Theme
.
of
(
context
).
splashColor
,
containedInkWell:
config
.
containedInkWell
,
rectCallback:
config
.
containedInkWell
?
rectCallback
:
null
,
radius:
config
.
radius
,
onRemoved:
()
{
if
(
_splashes
!=
null
)
{
assert
(
_splashes
.
contains
(
splash
));
...
...
packages/flutter/lib/src/material/material.dart
View file @
90504b12
...
...
@@ -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
,
...
...
packages/flutter/test/material/icon_button_test.dart
View file @
90504b12
...
...
@@ -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
)
,
)
]
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment