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
ba53b559
Unverified
Commit
ba53b559
authored
Mar 23, 2022
by
CHAHBOUN Mohammed
Committed by
GitHub
Mar 23, 2022
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add child for placeholder widget (#100372)
parent
0712e193
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
27 additions
and
21 deletions
+27
-21
timeline_test.dart
dev/tracing_tests/test/timeline_test.dart
+2
-2
placeholder.dart
packages/flutter/lib/src/widgets/placeholder.dart
+8
-1
keep_alive_test.dart
packages/flutter/test/widgets/keep_alive_test.dart
+9
-18
placeholder_test.dart
packages/flutter/test/widgets/placeholder_test.dart
+8
-0
No files found.
dev/tracing_tests/test/timeline_test.dart
View file @
ba53b559
...
...
@@ -120,7 +120,7 @@ void main() {
args
=
(
events
.
where
((
TimelineEvent
event
)
=>
event
.
json
![
'name'
]
==
'
$RenderCustomPaint
'
).
single
.
json
![
'args'
]
as
Map
<
String
,
Object
?>).
cast
<
String
,
String
>();
expect
(
args
[
'creator'
],
startsWith
(
'CustomPaint'
));
expect
(
args
[
'creator'
],
contains
(
'Placeholder'
));
expect
(
args
[
'
foregroundP
ainter'
],
startsWith
(
'_PlaceholderPainter#'
));
expect
(
args
[
'
p
ainter'
],
startsWith
(
'_PlaceholderPainter#'
));
debugProfileLayoutsEnabled
=
false
;
debugProfilePaintsEnabled
=
true
;
...
...
@@ -133,7 +133,7 @@ void main() {
args
=
(
events
.
where
((
TimelineEvent
event
)
=>
event
.
json
![
'name'
]
==
'
$RenderCustomPaint
'
).
single
.
json
![
'args'
]
as
Map
<
String
,
Object
?>).
cast
<
String
,
String
>();
expect
(
args
[
'creator'
],
startsWith
(
'CustomPaint'
));
expect
(
args
[
'creator'
],
contains
(
'Placeholder'
));
expect
(
args
[
'
foregroundP
ainter'
],
startsWith
(
'_PlaceholderPainter#'
));
expect
(
args
[
'
p
ainter'
],
startsWith
(
'_PlaceholderPainter#'
));
debugProfilePaintsEnabled
=
false
;
},
skip:
isBrowser
);
// [intended] uses dart:isolate and io.
...
...
packages/flutter/lib/src/widgets/placeholder.dart
View file @
ba53b559
...
...
@@ -59,6 +59,7 @@ class Placeholder extends StatelessWidget {
this
.
strokeWidth
=
2.0
,
this
.
fallbackWidth
=
400.0
,
this
.
fallbackHeight
=
400.0
,
this
.
child
})
:
super
(
key:
key
);
/// The color to draw the placeholder box.
...
...
@@ -83,6 +84,10 @@ class Placeholder extends StatelessWidget {
/// * [fallbackWidth], the same but horizontally.
final
double
fallbackHeight
;
/// The [child] contained by the placeholder box.
///
/// Defaults to null.
final
Widget
?
child
;
@override
Widget
build
(
BuildContext
context
)
{
return
LimitedBox
(
...
...
@@ -90,10 +95,11 @@ class Placeholder extends StatelessWidget {
maxHeight:
fallbackHeight
,
child:
CustomPaint
(
size:
Size
.
infinite
,
foregroundP
ainter:
_PlaceholderPainter
(
p
ainter:
_PlaceholderPainter
(
color:
color
,
strokeWidth:
strokeWidth
,
),
child:
child
,
),
);
}
...
...
@@ -105,5 +111,6 @@ class Placeholder extends StatelessWidget {
properties
.
add
(
DoubleProperty
(
'strokeWidth'
,
strokeWidth
,
defaultValue:
2.0
));
properties
.
add
(
DoubleProperty
(
'fallbackWidth'
,
fallbackWidth
,
defaultValue:
400.0
));
properties
.
add
(
DoubleProperty
(
'fallbackHeight'
,
fallbackHeight
,
defaultValue:
400.0
));
properties
.
add
(
DiagnosticsProperty
<
Widget
>(
'child'
,
child
,
defaultValue:
null
));
}
}
packages/flutter/test/widgets/keep_alive_test.dart
View file @
ba53b559
...
...
@@ -327,8 +327,7 @@ void main() {
' │ parentData: <none> (can use size)
\n
'
' │ constraints: BoxConstraints(w=800.0, h=400.0)
\n
'
' │ size: Size(800.0, 400.0)
\n
'
' │ painter: null
\n
'
' │ foregroundPainter: _PlaceholderPainter#00000()
\n
'
' │ painter: _PlaceholderPainter#00000()
\n
'
' │ preferredSize: Size(Infinity, Infinity)
\n
'
' │
\n
'
' ├─child with index 1: RenderLimitedBox#00000
\n
'
// <----- no dashed line starts here
...
...
@@ -342,8 +341,7 @@ void main() {
' │ parentData: <none> (can use size)
\n
'
' │ constraints: BoxConstraints(w=800.0, h=400.0)
\n
'
' │ size: Size(800.0, 400.0)
\n
'
' │ painter: null
\n
'
' │ foregroundPainter: _PlaceholderPainter#00000()
\n
'
' │ painter: _PlaceholderPainter#00000()
\n
'
' │ preferredSize: Size(Infinity, Infinity)
\n
'
' │
\n
'
' └─child with index 2: RenderLimitedBox#00000 NEEDS-PAINT
\n
'
...
...
@@ -357,8 +355,7 @@ void main() {
' parentData: <none> (can use size)
\n
'
' constraints: BoxConstraints(w=800.0, h=400.0)
\n
'
' size: Size(800.0, 400.0)
\n
'
' painter: null
\n
'
' foregroundPainter: _PlaceholderPainter#00000()
\n
'
' painter: _PlaceholderPainter#00000()
\n
'
' preferredSize: Size(Infinity, Infinity)
\n
'
,
));
const
GlobalObjectKey
<
_LeafState
>(
0
).
currentState
!.
setKeepAlive
(
true
);
...
...
@@ -490,8 +487,7 @@ void main() {
' │ parentData: <none> (can use size)
\n
'
' │ constraints: BoxConstraints(w=800.0, h=400.0)
\n
'
' │ size: Size(800.0, 400.0)
\n
'
' │ painter: null
\n
'
' │ foregroundPainter: _PlaceholderPainter#00000()
\n
'
' │ painter: _PlaceholderPainter#00000()
\n
'
' │ preferredSize: Size(Infinity, Infinity)
\n
'
' │
\n
'
' ├─child with index 5: RenderLimitedBox#00000
\n
'
// <----- this is index 5, not 0
...
...
@@ -505,8 +501,7 @@ void main() {
' │ parentData: <none> (can use size)
\n
'
' │ constraints: BoxConstraints(w=800.0, h=400.0)
\n
'
' │ size: Size(800.0, 400.0)
\n
'
' │ painter: null
\n
'
' │ foregroundPainter: _PlaceholderPainter#00000()
\n
'
' │ painter: _PlaceholderPainter#00000()
\n
'
' │ preferredSize: Size(Infinity, Infinity)
\n
'
' │
\n
'
' ├─child with index 6: RenderLimitedBox#00000
\n
'
...
...
@@ -520,8 +515,7 @@ void main() {
' │ parentData: <none> (can use size)
\n
'
' │ constraints: BoxConstraints(w=800.0, h=400.0)
\n
'
' │ size: Size(800.0, 400.0)
\n
'
' │ painter: null
\n
'
' │ foregroundPainter: _PlaceholderPainter#00000()
\n
'
' │ painter: _PlaceholderPainter#00000()
\n
'
' │ preferredSize: Size(Infinity, Infinity)
\n
'
' │
\n
'
' ├─child with index 7: RenderLimitedBox#00000 NEEDS-PAINT
\n
'
...
...
@@ -535,8 +529,7 @@ void main() {
' ╎ parentData: <none> (can use size)
\n
'
' ╎ constraints: BoxConstraints(w=800.0, h=400.0)
\n
'
' ╎ size: Size(800.0, 400.0)
\n
'
' ╎ painter: null
\n
'
' ╎ foregroundPainter: _PlaceholderPainter#00000()
\n
'
' ╎ painter: _PlaceholderPainter#00000()
\n
'
' ╎ preferredSize: Size(Infinity, Infinity)
\n
'
' ╎
\n
'
' ╎╌child with index 0 (kept alive but not laid out): RenderLimitedBox#00000
\n
'
// <----- this one is index 0 and is marked as being kept alive but not laid out
...
...
@@ -550,8 +543,7 @@ void main() {
' ╎ parentData: <none> (can use size)
\n
'
' ╎ constraints: BoxConstraints(w=800.0, h=400.0)
\n
'
' ╎ size: Size(800.0, 400.0)
\n
'
' ╎ painter: null
\n
'
' ╎ foregroundPainter: _PlaceholderPainter#00000()
\n
'
' ╎ painter: _PlaceholderPainter#00000()
\n
'
' ╎ preferredSize: Size(Infinity, Infinity)
\n
'
' ╎
\n
'
// <----- dashed line ends here
' └╌child with index 3 (kept alive but not laid out): RenderLimitedBox#00000
\n
'
...
...
@@ -565,8 +557,7 @@ void main() {
' parentData: <none> (can use size)
\n
'
' constraints: BoxConstraints(w=800.0, h=400.0)
\n
'
' size: Size(800.0, 400.0)
\n
'
' painter: null
\n
'
' foregroundPainter: _PlaceholderPainter#00000()
\n
'
' painter: _PlaceholderPainter#00000()
\n
'
' preferredSize: Size(Infinity, Infinity)
\n
'
,
));
},
skip:
kIsWeb
);
// https://github.com/flutter/flutter/issues/87876
...
...
packages/flutter/test/widgets/placeholder_test.dart
View file @
ba53b559
...
...
@@ -2,6 +2,7 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
import
'package:flutter/material.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
...
...
@@ -34,4 +35,11 @@ void main() {
await
tester
.
pumpWidget
(
const
Placeholder
(
strokeWidth:
10.0
));
expect
(
tester
.
renderObject
(
find
.
byType
(
Placeholder
)),
paints
..
path
(
strokeWidth:
10.0
));
});
testWidgets
(
'Placeholder child widget'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
const
Placeholder
());
expect
(
find
.
text
(
'Label'
),
findsNothing
);
await
tester
.
pumpWidget
(
const
MaterialApp
(
home:
Placeholder
(
child:
Text
(
'Label'
))));
expect
(
find
.
text
(
'Label'
),
findsOneWidget
);
});
}
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