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
66597ffb
Unverified
Commit
66597ffb
authored
Aug 10, 2021
by
Viren Khatri
Committed by
GitHub
Aug 10, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed mouse cursor of disabled IconButton (#84946)
parent
1ca0333c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
72 additions
and
4 deletions
+72
-4
icon_button.dart
packages/flutter/lib/src/material/icon_button.dart
+6
-4
icon_button_test.dart
packages/flutter/test/material/icon_button_test.dart
+66
-0
No files found.
packages/flutter/lib/src/material/icon_button.dart
View file @
66597ffb
...
...
@@ -153,7 +153,7 @@ class IconButton extends StatelessWidget {
this
.
splashColor
,
this
.
disabledColor
,
required
this
.
onPressed
,
this
.
mouseCursor
=
SystemMouseCursors
.
click
,
this
.
mouseCursor
,
this
.
focusNode
,
this
.
autofocus
=
false
,
this
.
tooltip
,
...
...
@@ -280,8 +280,10 @@ class IconButton extends StatelessWidget {
/// {@macro flutter.material.RawMaterialButton.mouseCursor}
///
/// Defaults to [SystemMouseCursors.click].
final
MouseCursor
mouseCursor
;
/// If set to null, will default to
/// - [SystemMouseCursors.forbidden], if [onPressed] is null
/// - [SystemMouseCursors.click], otherwise
final
MouseCursor
?
mouseCursor
;
/// {@macro flutter.widgets.Focus.focusNode}
final
FocusNode
?
focusNode
;
...
...
@@ -379,7 +381,7 @@ class IconButton extends StatelessWidget {
autofocus:
autofocus
,
canRequestFocus:
onPressed
!=
null
,
onTap:
onPressed
,
mouseCursor:
mouseCursor
,
mouseCursor:
mouseCursor
??
(
onPressed
==
null
?
SystemMouseCursors
.
forbidden
:
SystemMouseCursors
.
click
)
,
enableFeedback:
enableFeedback
,
focusColor:
focusColor
??
theme
.
focusColor
,
hoverColor:
hoverColor
??
theme
.
hoverColor
,
...
...
packages/flutter/test/material/icon_button_test.dart
View file @
66597ffb
...
...
@@ -680,6 +680,72 @@ void main() {
expect
(
RendererBinding
.
instance
!.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
click
);
});
testWidgets
(
'disabled IconButton has forbidden mouse cursor'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
Material
(
child:
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Center
(
child:
IconButton
(
onPressed:
null
,
// null value indicates IconButton is disabled
icon:
Icon
(
Icons
.
play_arrow
),
),
),
),
),
);
final
TestGesture
gesture
=
await
tester
.
createGesture
(
kind:
PointerDeviceKind
.
mouse
,
pointer:
1
);
await
gesture
.
addPointer
(
location:
tester
.
getCenter
(
find
.
byType
(
IconButton
)));
addTearDown
(
gesture
.
removePointer
);
await
tester
.
pump
();
expect
(
RendererBinding
.
instance
!.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
forbidden
);
});
testWidgets
(
'IconButton.mouseCursor overrides implicit setting of mouse cursor'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
Material
(
child:
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Center
(
child:
IconButton
(
onPressed:
null
,
mouseCursor:
SystemMouseCursors
.
none
,
icon:
Icon
(
Icons
.
play_arrow
),
),
),
),
),
);
final
TestGesture
gesture
=
await
tester
.
createGesture
(
kind:
PointerDeviceKind
.
mouse
,
pointer:
1
);
await
gesture
.
addPointer
(
location:
tester
.
getCenter
(
find
.
byType
(
IconButton
)));
addTearDown
(
gesture
.
removePointer
);
await
tester
.
pump
();
expect
(
RendererBinding
.
instance
!.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
none
);
await
tester
.
pumpWidget
(
Material
(
child:
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
Center
(
child:
IconButton
(
onPressed:
()
{},
mouseCursor:
SystemMouseCursors
.
none
,
icon:
const
Icon
(
Icons
.
play_arrow
),
),
),
),
),
);
expect
(
RendererBinding
.
instance
!.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
none
);
});
}
Widget
wrap
(
{
required
Widget
child
})
{
...
...
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