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
4b902c79
Unverified
Commit
4b902c79
authored
Mar 04, 2022
by
Taha Tesser
Committed by
GitHub
Mar 04, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
CupertinoButton: Add clickable cursor on web (#96863)
parent
d61caaad
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
37 deletions
+69
-37
button.dart
packages/flutter/lib/src/cupertino/button.dart
+40
-37
button_test.dart
packages/flutter/test/cupertino/button_test.dart
+29
-0
No files found.
packages/flutter/lib/src/cupertino/button.dart
View file @
4b902c79
...
...
@@ -245,7 +245,9 @@ class _CupertinoButtonState extends State<CupertinoButton> with SingleTickerProv
final
TextStyle
textStyle
=
themeData
.
textTheme
.
textStyle
.
copyWith
(
color:
foregroundColor
);
return
GestureDetector
(
return
MouseRegion
(
cursor:
enabled
&&
kIsWeb
?
SystemMouseCursors
.
click
:
MouseCursor
.
defer
,
child:
GestureDetector
(
behavior:
HitTestBehavior
.
opaque
,
onTapDown:
enabled
?
_handleTapDown
:
null
,
onTapUp:
enabled
?
_handleTapUp
:
null
,
...
...
@@ -290,6 +292,7 @@ class _CupertinoButtonState extends State<CupertinoButton> with SingleTickerProv
),
),
),
),
);
}
}
packages/flutter/test/cupertino/button_test.dart
View file @
4b902c79
...
...
@@ -3,6 +3,8 @@
// found in the LICENSE file.
import
'package:flutter/cupertino.dart'
;
import
'package:flutter/foundation.dart'
;
import
'package:flutter/gestures.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/scheduler.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
@@ -451,6 +453,33 @@ void main() {
).
decoration
as
BoxDecoration
;
expect
(
decoration
.
color
,
isSameColorAs
(
CupertinoColors
.
systemBlue
.
darkColor
));
});
testWidgets
(
'Hovering over Cupertino button updates cursor to clickable on Web'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
CupertinoApp
(
home:
Center
(
child:
CupertinoButton
.
filled
(
onPressed:
()
{
},
child:
const
Text
(
'Tap me'
),
),
),
),
);
final
TestGesture
gesture
=
await
tester
.
createGesture
(
kind:
PointerDeviceKind
.
mouse
,
pointer:
1
);
await
gesture
.
addPointer
(
location:
const
Offset
(
10
,
10
));
await
tester
.
pumpAndSettle
();
expect
(
RendererBinding
.
instance
.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
SystemMouseCursors
.
basic
);
final
Offset
button
=
tester
.
getCenter
(
find
.
byType
(
CupertinoButton
));
await
gesture
.
moveTo
(
button
);
addTearDown
(
gesture
.
removePointer
);
await
tester
.
pumpAndSettle
();
expect
(
RendererBinding
.
instance
.
mouseTracker
.
debugDeviceActiveCursor
(
1
),
kIsWeb
?
SystemMouseCursors
.
click
:
SystemMouseCursors
.
basic
,
);
});
}
Widget
boilerplate
(
{
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