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
589b3278
Unverified
Commit
589b3278
authored
Jul 09, 2020
by
chunhtai
Committed by
GitHub
Jul 09, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Issues/58665 reland and prevent the material widget from absorbing gesture (#60536)
parent
e2a638e6
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
89 additions
and
3 deletions
+89
-3
app_bar.dart
packages/flutter/lib/src/material/app_bar.dart
+6
-1
material.dart
packages/flutter/lib/src/material/material.dart
+11
-2
app_bar_test.dart
packages/flutter/test/material/app_bar_test.dart
+43
-0
material_test.dart
packages/flutter/test/material/material_test.dart
+29
-0
No files found.
packages/flutter/lib/src/material/app_bar.dart
View file @
589b3278
...
...
@@ -681,7 +681,12 @@ class _AppBarState extends State<AppBar> {
fit:
StackFit
.
passthrough
,
children:
<
Widget
>[
widget
.
flexibleSpace
,
appBar
,
// Creates a material widget to prevent the flexibleSpace from
// obscuring the ink splashes produced by appBar children.
Material
(
type:
MaterialType
.
transparency
,
child:
appBar
,
),
],
);
}
...
...
packages/flutter/lib/src/material/material.dart
View file @
589b3278
...
...
@@ -366,6 +366,7 @@ class _MaterialState extends State<Material> with TickerProviderStateMixin {
},
child:
_InkFeatures
(
key:
_inkFeatureRenderer
,
absorbHitTest:
widget
.
type
!=
MaterialType
.
transparency
,
color:
backgroundColor
,
child:
contents
,
vsync:
this
,
...
...
@@ -477,6 +478,7 @@ class _RenderInkFeatures extends RenderProxyBox implements MaterialInkController
_RenderInkFeatures
({
RenderBox
child
,
@required
this
.
vsync
,
this
.
absorbHitTest
,
this
.
color
,
})
:
assert
(
vsync
!=
null
),
super
(
child
);
...
...
@@ -493,6 +495,8 @@ class _RenderInkFeatures extends RenderProxyBox implements MaterialInkController
@override
Color
color
;
bool
absorbHitTest
;
List
<
InkFeature
>
_inkFeatures
;
@override
...
...
@@ -517,7 +521,7 @@ class _RenderInkFeatures extends RenderProxyBox implements MaterialInkController
}
@override
bool
hitTestSelf
(
Offset
position
)
=>
true
;
bool
hitTestSelf
(
Offset
position
)
=>
absorbHitTest
;
@override
void
paint
(
PaintingContext
context
,
Offset
offset
)
{
...
...
@@ -539,6 +543,7 @@ class _InkFeatures extends SingleChildRenderObjectWidget {
Key
key
,
this
.
color
,
@required
this
.
vsync
,
@required
this
.
absorbHitTest
,
Widget
child
,
})
:
super
(
key:
key
,
child:
child
);
...
...
@@ -549,17 +554,21 @@ class _InkFeatures extends SingleChildRenderObjectWidget {
final
TickerProvider
vsync
;
final
bool
absorbHitTest
;
@override
_RenderInkFeatures
createRenderObject
(
BuildContext
context
)
{
return
_RenderInkFeatures
(
color:
color
,
absorbHitTest:
absorbHitTest
,
vsync:
vsync
,
);
}
@override
void
updateRenderObject
(
BuildContext
context
,
_RenderInkFeatures
renderObject
)
{
renderObject
.
color
=
color
;
renderObject
..
color
=
color
..
absorbHitTest
=
absorbHitTest
;
assert
(
vsync
==
renderObject
.
vsync
);
}
}
...
...
packages/flutter/test/material/app_bar_test.dart
View file @
589b3278
...
...
@@ -10,6 +10,7 @@ import 'package:flutter/rendering.dart';
import
'package:flutter/services.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'../rendering/mock_canvas.dart'
;
import
'../widgets/semantics_tester.dart'
;
Widget
buildSliverAppBarApp
(
{
...
...
@@ -1103,6 +1104,48 @@ void main() {
expect
(
find
.
byIcon
(
Icons
.
menu
),
findsNothing
);
});
testWidgets
(
'AppBar ink splash draw on the correct canvas'
,
(
WidgetTester
tester
)
async
{
// This is a regression test for https://github.com/flutter/flutter/issues/58665
final
Key
key
=
UniqueKey
();
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Center
(
child:
AppBar
(
title:
const
Text
(
'Abc'
),
actions:
<
Widget
>[
IconButton
(
key:
key
,
icon:
const
Icon
(
Icons
.
add_circle
),
tooltip:
'First button'
,
onPressed:
()
{},
),
],
flexibleSpace:
DecoratedBox
(
decoration:
BoxDecoration
(
gradient:
LinearGradient
(
begin:
const
Alignment
(
0.0
,
-
1.0
),
end:
const
Alignment
(-
0.04
,
1.0
),
colors:
<
Color
>[
Colors
.
blue
.
shade500
,
Colors
.
blue
.
shade800
],
),
),
),
),
),
),
);
final
RenderObject
painter
=
tester
.
renderObject
(
find
.
descendant
(
of:
find
.
descendant
(
of:
find
.
byType
(
AppBar
),
matching:
find
.
byType
(
Stack
),
),
matching:
find
.
byType
(
Material
)
)
);
await
tester
.
tap
(
find
.
byKey
(
key
));
expect
(
painter
,
paints
..
save
()..
translate
()..
save
()..
translate
()..
circle
(
x:
24.0
,
y:
28.0
));
});
testWidgets
(
'AppBar handles loose children 0'
,
(
WidgetTester
tester
)
async
{
final
GlobalKey
key
=
GlobalKey
();
await
tester
.
pumpWidget
(
...
...
packages/flutter/test/material/material_test.dart
View file @
589b3278
...
...
@@ -219,6 +219,35 @@ void main() {
expect
(
modelE
.
shadowColor
,
equals
(
const
Color
(
0xFFFF0000
)));
});
testWidgets
(
'Transparent material widget does not absorb hit test'
,
(
WidgetTester
tester
)
async
{
// This is a regression test for https://github.com/flutter/flutter/issues/58665.
bool
pressed
=
false
;
await
tester
.
pumpWidget
(
MaterialApp
(
home:
Scaffold
(
body:
Stack
(
children:
<
Widget
>[
RaisedButton
(
onPressed:
()
{
pressed
=
true
;
},
),
Material
(
type:
MaterialType
.
transparency
,
child:
Container
(
width:
400.0
,
height:
500.0
,
),
),
],
),
),
),
);
await
tester
.
tap
(
find
.
byType
(
RaisedButton
));
expect
(
pressed
,
isTrue
);
});
group
(
'Elevation Overlay'
,
()
{
testWidgets
(
'applyElevationOverlayColor set to false does not change surface color'
,
(
WidgetTester
tester
)
async
{
...
...
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