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
6def1596
Unverified
Commit
6def1596
authored
Apr 12, 2022
by
Jonah Williams
Committed by
GitHub
Apr 12, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[framework] introduce repaint boundary in Opacity widgets (#101601)
parent
2d9e1718
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
88 additions
and
22 deletions
+88
-22
basic.dart
packages/flutter/lib/src/widgets/basic.dart
+41
-10
implicit_animations.dart
packages/flutter/lib/src/widgets/implicit_animations.dart
+3
-1
transitions.dart
packages/flutter/lib/src/widgets/transitions.dart
+41
-10
nav_bar_test.dart
packages/flutter/test/cupertino/nav_bar_test.dart
+1
-1
debug_test.dart
packages/flutter/test/material/debug_test.dart
+2
-0
No files found.
packages/flutter/lib/src/widgets/basic.dart
View file @
6def1596
...
...
@@ -242,7 +242,7 @@ class Directionality extends InheritedWidget {
/// opacity.
/// * [Image], which can directly provide a partially transparent image with
/// much less performance hit.
class
Opacity
extends
S
ingleChildRenderObject
Widget
{
class
Opacity
extends
S
tateless
Widget
{
/// Creates a widget that makes its child partially transparent.
///
/// The [opacity] argument must not be null and must be between 0.0 and 1.0
...
...
@@ -251,10 +251,10 @@ class Opacity extends SingleChildRenderObjectWidget {
Key
?
key
,
required
this
.
opacity
,
this
.
alwaysIncludeSemantics
=
false
,
Widget
?
child
,
this
.
child
,
})
:
assert
(
opacity
!=
null
&&
opacity
>=
0.0
&&
opacity
<=
1.0
),
assert
(
alwaysIncludeSemantics
!=
null
),
super
(
key:
key
,
child:
child
);
super
(
key:
key
);
/// The fraction to scale the child's alpha value.
///
...
...
@@ -278,6 +278,44 @@ class Opacity extends SingleChildRenderObjectWidget {
/// would otherwise contribute relevant semantics.
final
bool
alwaysIncludeSemantics
;
/// The widget below this widget in the tree.
///
/// {@macro flutter.widgets.ProxyWidget.child}
final
Widget
?
child
;
@override
Widget
build
(
BuildContext
context
)
{
return
_Opacity
(
opacity:
opacity
,
alwaysIncludeSemantics:
alwaysIncludeSemantics
,
child:
RepaintBoundary
(
child:
child
,
),
);
}
@override
void
debugFillProperties
(
DiagnosticPropertiesBuilder
properties
)
{
super
.
debugFillProperties
(
properties
);
properties
.
add
(
DoubleProperty
(
'opacity'
,
opacity
));
properties
.
add
(
FlagProperty
(
'alwaysIncludeSemantics'
,
value:
alwaysIncludeSemantics
,
ifTrue:
'alwaysIncludeSemantics'
));
}
}
/// The backing implementation of [Opacity].
class
_Opacity
extends
SingleChildRenderObjectWidget
{
const
_Opacity
({
Key
?
key
,
required
this
.
opacity
,
this
.
alwaysIncludeSemantics
=
false
,
Widget
?
child
,
})
:
assert
(
opacity
!=
null
&&
opacity
>=
0.0
&&
opacity
<=
1.0
),
assert
(
alwaysIncludeSemantics
!=
null
),
super
(
key:
key
,
child:
child
);
final
double
opacity
;
final
bool
alwaysIncludeSemantics
;
@override
RenderOpacity
createRenderObject
(
BuildContext
context
)
{
return
RenderOpacity
(
...
...
@@ -292,13 +330,6 @@ class Opacity extends SingleChildRenderObjectWidget {
..
opacity
=
opacity
..
alwaysIncludeSemantics
=
alwaysIncludeSemantics
;
}
@override
void
debugFillProperties
(
DiagnosticPropertiesBuilder
properties
)
{
super
.
debugFillProperties
(
properties
);
properties
.
add
(
DoubleProperty
(
'opacity'
,
opacity
));
properties
.
add
(
FlagProperty
(
'alwaysIncludeSemantics'
,
value:
alwaysIncludeSemantics
,
ifTrue:
'alwaysIncludeSemantics'
));
}
}
/// A widget that applies a mask generated by a [Shader] to its child.
...
...
packages/flutter/lib/src/widgets/implicit_animations.dart
View file @
6def1596
...
...
@@ -1759,7 +1759,9 @@ class _AnimatedOpacityState extends ImplicitlyAnimatedWidgetState<AnimatedOpacit
return
FadeTransition
(
opacity:
_opacityAnimation
,
alwaysIncludeSemantics:
widget
.
alwaysIncludeSemantics
,
child:
widget
.
child
,
child:
RepaintBoundary
(
child:
widget
.
child
,
),
);
}
}
...
...
packages/flutter/lib/src/widgets/transitions.dart
View file @
6def1596
...
...
@@ -483,7 +483,7 @@ class SizeTransition extends AnimatedWidget {
/// * [Opacity], which does not animate changes in opacity.
/// * [AnimatedOpacity], which animates changes in opacity without taking an
/// explicit [Animation] argument.
class
FadeTransition
extends
S
ingleChildRenderObject
Widget
{
class
FadeTransition
extends
S
tateless
Widget
{
/// Creates an opacity transition.
///
/// The [opacity] argument must not be null.
...
...
@@ -491,9 +491,9 @@ class FadeTransition extends SingleChildRenderObjectWidget {
Key
?
key
,
required
this
.
opacity
,
this
.
alwaysIncludeSemantics
=
false
,
Widget
?
child
,
this
.
child
,
})
:
assert
(
opacity
!=
null
),
super
(
key:
key
,
child:
child
);
super
(
key:
key
);
/// The animation that controls the opacity of the child.
///
...
...
@@ -513,6 +513,44 @@ class FadeTransition extends SingleChildRenderObjectWidget {
/// would otherwise contribute relevant semantics.
final
bool
alwaysIncludeSemantics
;
/// The widget below this widget in the tree.
///
/// {@macro flutter.widgets.ProxyWidget.child}
final
Widget
?
child
;
@override
Widget
build
(
BuildContext
context
)
{
return
_FadeTransition
(
opacity:
opacity
,
alwaysIncludeSemantics:
alwaysIncludeSemantics
,
child:
RepaintBoundary
(
child:
child
,
),
);
}
@override
void
debugFillProperties
(
DiagnosticPropertiesBuilder
properties
)
{
super
.
debugFillProperties
(
properties
);
properties
.
add
(
DiagnosticsProperty
<
Animation
<
double
>>(
'opacity'
,
opacity
));
properties
.
add
(
FlagProperty
(
'alwaysIncludeSemantics'
,
value:
alwaysIncludeSemantics
,
ifTrue:
'alwaysIncludeSemantics'
));
}
}
/// The backing implementation of a [FadeTransition].
class
_FadeTransition
extends
SingleChildRenderObjectWidget
{
const
_FadeTransition
({
Key
?
key
,
required
this
.
opacity
,
this
.
alwaysIncludeSemantics
=
false
,
Widget
?
child
,
})
:
assert
(
opacity
!=
null
),
super
(
key:
key
,
child:
child
);
final
Animation
<
double
>
opacity
;
final
bool
alwaysIncludeSemantics
;
@override
RenderAnimatedOpacity
createRenderObject
(
BuildContext
context
)
{
return
RenderAnimatedOpacity
(
...
...
@@ -527,13 +565,6 @@ class FadeTransition extends SingleChildRenderObjectWidget {
..
opacity
=
opacity
..
alwaysIncludeSemantics
=
alwaysIncludeSemantics
;
}
@override
void
debugFillProperties
(
DiagnosticPropertiesBuilder
properties
)
{
super
.
debugFillProperties
(
properties
);
properties
.
add
(
DiagnosticsProperty
<
Animation
<
double
>>(
'opacity'
,
opacity
));
properties
.
add
(
FlagProperty
(
'alwaysIncludeSemantics'
,
value:
alwaysIncludeSemantics
,
ifTrue:
'alwaysIncludeSemantics'
));
}
}
/// Animates the opacity of a sliver widget.
...
...
packages/flutter/test/cupertino/nav_bar_test.dart
View file @
6def1596
...
...
@@ -951,7 +951,7 @@ void main() {
);
await
expectLater
(
find
.
byType
(
RepaintBoundary
).
la
st
,
find
.
byType
(
RepaintBoundary
).
fir
st
,
matchesGoldenFile
(
'nav_bar_test.large_title.png'
),
);
},
...
...
packages/flutter/test/material/debug_test.dart
View file @
6def1596
...
...
@@ -128,6 +128,8 @@ void main() {
' RepaintBoundary-[GlobalKey#00000]
\n
'
' IgnorePointer
\n
'
' AnimatedBuilder
\n
'
' RepaintBoundary
\n
'
' _FadeTransition
\n
'
' FadeTransition
\n
'
' FractionalTranslation
\n
'
' SlideTransition
\n
'
...
...
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