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
e4a909fb
Unverified
Commit
e4a909fb
authored
Aug 08, 2019
by
Tong Mu
Committed by
GitHub
Aug 08, 2019
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix mouse region double render (#37344)
Fix an issue where MouseRegion will render its children twice.
parent
62674cee
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
90 additions
and
1 deletion
+90
-1
proxy_box.dart
packages/flutter/lib/src/rendering/proxy_box.dart
+2
-1
mouse_region_test.dart
packages/flutter/test/widgets/mouse_region_test.dart
+88
-0
No files found.
packages/flutter/lib/src/rendering/proxy_box.dart
View file @
e4a909fb
...
...
@@ -2727,8 +2727,9 @@ class RenderMouseRegion extends RenderProxyBox {
offset:
offset
,
);
context
.
pushLayer
(
layer
,
super
.
paint
,
offset
);
}
else
{
super
.
paint
(
context
,
offset
);
}
super
.
paint
(
context
,
offset
);
}
@override
...
...
packages/flutter/test/widgets/mouse_region_test.dart
View file @
e4a909fb
...
...
@@ -623,4 +623,92 @@ void main() {
expect
(
exit
.
single
.
delta
,
const
Offset
(
0.0
,
0.0
));
});
});
group
(
'MouseRegion paints child once and only once'
,
()
{
testWidgets
(
'When MouseRegion is inactive'
,
(
WidgetTester
tester
)
async
{
int
paintCount
=
0
;
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
MouseRegion
(
onEnter:
(
PointerEnterEvent
e
)
{},
child:
_PaintDelegateWidget
(
onPaint:
_VoidDelegate
(()
=>
paintCount
++),
child:
const
Text
(
'123'
),
),
),
),
);
expect
(
paintCount
,
1
);
});
testWidgets
(
'When MouseRegion is active'
,
(
WidgetTester
tester
)
async
{
int
paintCount
=
0
;
final
TestGesture
gesture
=
await
tester
.
createGesture
(
kind:
PointerDeviceKind
.
mouse
);
await
gesture
.
addPointer
();
await
tester
.
pumpWidget
(
Directionality
(
textDirection:
TextDirection
.
ltr
,
child:
MouseRegion
(
onEnter:
(
PointerEnterEvent
e
)
{},
child:
_PaintDelegateWidget
(
onPaint:
_VoidDelegate
(()
=>
paintCount
++),
child:
const
Text
(
'123'
),
),
),
),
);
expect
(
paintCount
,
1
);
await
gesture
.
removePointer
();
});
});
}
// This widget allows you to send a callback that is called during `onPaint.
@immutable
class
_PaintDelegateWidget
extends
SingleChildRenderObjectWidget
{
const
_PaintDelegateWidget
({
Key
key
,
Widget
child
,
this
.
onPaint
,
})
:
super
(
key:
key
,
child:
child
);
final
_VoidDelegate
onPaint
;
@override
RenderObject
createRenderObject
(
BuildContext
context
)
{
return
_PaintCallbackObject
(
onPaint:
onPaint
?.
callback
);
}
@override
void
updateRenderObject
(
BuildContext
context
,
_PaintCallbackObject
renderObject
)
{
renderObject
..
onPaint
=
onPaint
?.
callback
;
}
}
class
_VoidDelegate
{
_VoidDelegate
(
this
.
callback
);
void
Function
()
callback
;
}
class
_PaintCallbackObject
extends
RenderProxyBox
{
_PaintCallbackObject
({
RenderObject
child
,
this
.
onPaint
,
})
:
super
(
child
);
void
Function
()
onPaint
;
@override
void
paint
(
PaintingContext
context
,
Offset
offset
)
{
if
(
onPaint
!=
null
)
onPaint
();
super
.
paint
(
context
,
offset
);
}
}
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