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
b361a3b4
Commit
b361a3b4
authored
Sep 21, 2015
by
Adam Barth
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
fn3 shouldn't rebuild components that don't change identity
parent
5fdd996e
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
35 additions
and
4 deletions
+35
-4
framework.dart
packages/flutter/lib/src/fn3/framework.dart
+3
-0
stateful_component_test.dart
packages/unit/test/fn3/stateful_component_test.dart
+32
-4
No files found.
packages/flutter/lib/src/fn3/framework.dart
View file @
b361a3b4
...
...
@@ -204,6 +204,9 @@ abstract class Element<T extends Widget> {
}
if
(
child
!=
null
)
{
assert
(
child
.
_slot
==
slot
);
if
(
child
.
_widget
==
updated
)
return
child
;
if
(
_canUpdate
(
child
.
_widget
,
updated
))
{
child
.
update
(
updated
);
return
child
;
...
...
packages/unit/test/fn3/stateful_component_test.dart
View file @
b361a3b4
...
...
@@ -32,6 +32,21 @@ class TestComponentState extends ComponentState {
final
BoxDecoration
kBoxDecorationA
=
new
BoxDecoration
();
final
BoxDecoration
kBoxDecorationB
=
new
BoxDecoration
();
class
TestBuildCounter
extends
Component
{
static
int
buildCount
=
0
;
Widget
build
()
{
++
buildCount
;
return
new
DecoratedBox
(
decoration:
kBoxDecorationA
);
}
}
void
flipStatefulComponent
(
WidgetTester
tester
)
{
ComponentStateElement
stateElement
=
tester
.
findElement
((
element
)
=>
element
is
ComponentStateElement
);
(
stateElement
.
state
as
TestComponentState
).
flip
();
}
void
main
(
)
{
test
(
'Stateful component smoke test'
,
()
{
WidgetTester
tester
=
new
WidgetTester
();
...
...
@@ -63,10 +78,7 @@ void main() {
checkTree
(
kBoxDecorationB
);
ComponentStateElement
stateElement
=
tester
.
findElement
((
element
)
=>
element
is
ComponentStateElement
);
(
stateElement
.
state
as
TestComponentState
).
flip
();
flipStatefulComponent
(
tester
);
Element
.
flushBuild
();
checkTree
(
kBoxDecorationA
);
...
...
@@ -82,4 +94,20 @@ void main() {
});
test
(
'Don
\'
t rebuild subcomponents'
,
()
{
WidgetTester
tester
=
new
WidgetTester
();
tester
.
pumpFrame
(
new
TestComponentConfig
(
left:
new
TestBuildCounter
(),
right:
new
DecoratedBox
(
decoration:
kBoxDecorationB
)
)
);
expect
(
TestBuildCounter
.
buildCount
,
equals
(
1
));
flipStatefulComponent
(
tester
);
Element
.
flushBuild
();
expect
(
TestBuildCounter
.
buildCount
,
equals
(
1
));
});
}
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