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
4dd3435b
Unverified
Commit
4dd3435b
authored
Apr 29, 2020
by
guylivneh
Committed by
GitHub
Apr 29, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add a property to Material icon button to customize the splash radius (#55761)
parent
9d770c10
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
39 additions
and
1 deletion
+39
-1
icon_button.dart
packages/flutter/lib/src/material/icon_button.dart
+8
-1
icon_button_test.dart
packages/flutter/test/material/icon_button_test.dart
+31
-0
No files found.
packages/flutter/lib/src/material/icon_button.dart
View file @
4dd3435b
...
...
@@ -142,6 +142,7 @@ class IconButton extends StatelessWidget {
this
.
visualDensity
,
this
.
padding
=
const
EdgeInsets
.
all
(
8.0
),
this
.
alignment
=
Alignment
.
center
,
this
.
splashRadius
,
@required
this
.
icon
,
this
.
color
,
this
.
focusColor
,
...
...
@@ -158,6 +159,7 @@ class IconButton extends StatelessWidget {
})
:
assert
(
iconSize
!=
null
),
assert
(
padding
!=
null
),
assert
(
alignment
!=
null
),
assert
(
splashRadius
==
null
||
splashRadius
>
0
),
assert
(
autofocus
!=
null
),
assert
(
icon
!=
null
),
super
(
key:
key
);
...
...
@@ -202,6 +204,11 @@ class IconButton extends StatelessWidget {
/// relative to text direction.
final
AlignmentGeometry
alignment
;
/// The splash radius.
///
/// If null, default splash radius of [Material.defaultSplashRadius] is used.
final
double
splashRadius
;
/// The icon to display inside the button.
///
/// The [Icon.size] and [Icon.color] of the icon is configured automatically
...
...
@@ -369,7 +376,7 @@ class IconButton extends StatelessWidget {
hoverColor:
hoverColor
??
Theme
.
of
(
context
).
hoverColor
,
highlightColor:
highlightColor
??
Theme
.
of
(
context
).
highlightColor
,
splashColor:
splashColor
??
Theme
.
of
(
context
).
splashColor
,
radius:
math
.
max
(
radius:
splashRadius
??
math
.
max
(
Material
.
defaultSplashRadius
,
(
iconSize
+
math
.
min
(
padding
.
horizontal
,
padding
.
vertical
))
*
0.7
,
// x 0.5 for diameter -> radius and + 40% overflow derived from other Material apps.
...
...
packages/flutter/test/material/icon_button_test.dart
View file @
4dd3435b
...
...
@@ -337,6 +337,37 @@ void main() {
await
gesture
.
up
();
});
testWidgets
(
'IconButton with explicit splash radius'
,
(
WidgetTester
tester
)
async
{
const
double
splashRadius
=
30.0
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Material
(
child:
Center
(
child:
IconButton
(
icon:
const
Icon
(
Icons
.
android
),
splashRadius:
splashRadius
,
onPressed:
()
{
/* enable the button */
},
),
),
),
),
);
final
Offset
center
=
tester
.
getCenter
(
find
.
byType
(
IconButton
));
final
TestGesture
gesture
=
await
tester
.
startGesture
(
center
);
await
tester
.
pump
();
// Start gesture.
await
tester
.
pump
(
const
Duration
(
milliseconds:
1000
));
// Wait for splash to be well under way.
expect
(
Material
.
of
(
tester
.
element
(
find
.
byType
(
IconButton
))),
paints
..
circle
(
radius:
splashRadius
)
);
await
gesture
.
up
();
});
testWidgets
(
'IconButton Semantics (enabled)'
,
(
WidgetTester
tester
)
async
{
final
SemanticsTester
semantics
=
SemanticsTester
(
tester
);
...
...
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