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
e2d0917e
Commit
e2d0917e
authored
Aug 15, 2016
by
Ian Hickson
Committed by
GitHub
Aug 15, 2016
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
GestureDetector fills its parent if child-less. (#5397)
Fixes
https://github.com/flutter/flutter/issues/5380
parent
c0a71e34
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
52 additions
and
2 deletions
+52
-2
proxy_box.dart
packages/flutter/lib/src/rendering/proxy_box.dart
+13
-2
basic.dart
packages/flutter/lib/src/widgets/basic.dart
+3
-0
gesture_detector.dart
packages/flutter/lib/src/widgets/gesture_detector.dart
+3
-0
gesture_detector_test.dart
packages/flutter/test/widget/gesture_detector_test.dart
+33
-0
No files found.
packages/flutter/lib/src/rendering/proxy_box.dart
View file @
e2d0917e
...
...
@@ -1713,6 +1713,10 @@ typedef void PointerUpEventListener(PointerUpEvent event);
typedef
void
PointerCancelEventListener
(
PointerCancelEvent
event
);
/// Calls callbacks in response to pointer events.
///
/// If it has a child, defers to the child for sizing behavior.
///
/// If it does not have a child, grows to fit the parent-provided constraints.
class
RenderPointerListener
extends
RenderProxyBoxWithHitTestBehavior
{
/// Creates a render object that forwards point events to callbacks.
///
...
...
@@ -1732,12 +1736,19 @@ class RenderPointerListener extends RenderProxyBoxWithHitTestBehavior {
/// Called when a pointer that triggered an [onPointerDown] changes position.
PointerMoveEventListener
onPointerMove
;
/// Called when a pointer that triggered an [onPointerDown] is no longer in contact with the screen.
/// Called when a pointer that triggered an [onPointerDown] is no longer in
/// contact with the screen.
PointerUpEventListener
onPointerUp
;
/// Called when the input from a pointer that triggered an [onPointerDown] is no longer directed towards this receiver.
/// Called when the input from a pointer that triggered an [onPointerDown] is
/// no longer directed towards this receiver.
PointerCancelEventListener
onPointerCancel
;
@override
void
performResize
()
{
size
=
constraints
.
biggest
;
}
@override
void
handleEvent
(
PointerEvent
event
,
HitTestEntry
entry
)
{
if
(
onPointerDown
!=
null
&&
event
is
PointerDownEvent
)
...
...
packages/flutter/lib/src/widgets/basic.dart
View file @
e2d0917e
...
...
@@ -2477,6 +2477,9 @@ class WidgetToRenderBoxAdapter extends LeafRenderObjectWidget {
///
/// Rather than listening for raw pointer events, consider listening for
/// higher-level gestures using [GestureDetector].
///
/// If it has a child, this widget defers to the child for sizing behavior. If
/// it does not have a child, it grows to fit the parent instead.
class
Listener
extends
SingleChildRenderObjectWidget
{
/// Creates a widget that forwards point events to callbacks.
///
...
...
packages/flutter/lib/src/widgets/gesture_detector.dart
View file @
e2d0917e
...
...
@@ -40,6 +40,9 @@ typedef GestureRecognizer GestureRecognizerFactory(GestureRecognizer recognizer)
///
/// Attempts to recognize gestures that correspond to its non-null callbacks.
///
/// If this widget has a child, it defers to that child for its sizing behavior.
/// If it does not have a child, it grows to fit the parent instead.
///
/// GestureDetector also listens for accessibility events and maps
/// them to the callbacks. To ignore accessibility events, set
/// [excludeFromSemantics] to true.
...
...
packages/flutter/test/widget/gesture_detector_test.dart
View file @
e2d0917e
...
...
@@ -190,4 +190,37 @@ void main() {
expect
(
didTap
,
isTrue
);
});
testWidgets
(
'Empty'
,
(
WidgetTester
tester
)
async
{
bool
didTap
=
false
;
await
tester
.
pumpWidget
(
new
Center
(
child:
new
GestureDetector
(
onTap:
()
{
didTap
=
true
;
},
)
)
);
expect
(
didTap
,
isFalse
);
await
tester
.
tapAt
(
new
Point
(
10.0
,
10.0
));
expect
(
didTap
,
isTrue
);
});
testWidgets
(
'Only container'
,
(
WidgetTester
tester
)
async
{
bool
didTap
=
false
;
await
tester
.
pumpWidget
(
new
Center
(
child:
new
GestureDetector
(
onTap:
()
{
didTap
=
true
;
},
child:
new
Container
(),
)
)
);
expect
(
didTap
,
isFalse
);
await
tester
.
tapAt
(
new
Point
(
10.0
,
10.0
));
expect
(
didTap
,
isFalse
);
});
}
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