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
62fdcb03
Unverified
Commit
62fdcb03
authored
Feb 04, 2020
by
Jenn Magder
Committed by
GitHub
Feb 04, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Fix custom Elements that wants to decorate State.build (#49925)" (#50068)
This reverts commit
a1143d17
.
parent
ef62d532
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
84 deletions
+7
-84
framework.dart
packages/flutter/lib/src/widgets/framework.dart
+7
-10
framework_test.dart
packages/flutter/test/widgets/framework_test.dart
+0
-74
No files found.
packages/flutter/lib/src/widgets/framework.dart
View file @
62fdcb03
...
...
@@ -4586,7 +4586,13 @@ class StatefulElement extends ComponentElement {
}
@override
Widget
build
()
=>
_state
.
build
(
this
);
Widget
build
()
{
if
(
_didChangeDependencies
)
{
_state
.
didChangeDependencies
();
_didChangeDependencies
=
false
;
}
return
state
.
build
(
this
);
}
/// The [State] instance associated with this location in the tree.
///
...
...
@@ -4636,15 +4642,6 @@ class StatefulElement extends ComponentElement {
super
.
_firstBuild
();
}
@override
void
performRebuild
()
{
if
(
_didChangeDependencies
)
{
_state
.
didChangeDependencies
();
_didChangeDependencies
=
false
;
}
super
.
performRebuild
();
}
@override
void
update
(
StatefulWidget
newWidget
)
{
super
.
update
(
newWidget
);
...
...
packages/flutter/test/widgets/framework_test.dart
View file @
62fdcb03
...
...
@@ -1259,80 +1259,6 @@ void main() {
expect
(
state
.
didChangeDependenciesCount
,
3
);
expect
(
state
.
deactivatedCount
,
2
);
});
testWidgets
(
'StatefulElement subclass can decorate State.build'
,
(
WidgetTester
tester
)
async
{
bool
isDidChangeDependenciesDecorated
;
bool
isBuildDecorated
;
final
Widget
child
=
Decorate
(
didChangeDependencies:
(
bool
value
)
{
isDidChangeDependenciesDecorated
=
value
;
},
build:
(
bool
value
)
{
isBuildDecorated
=
value
;
}
);
await
tester
.
pumpWidget
(
Inherited
(
0
,
child:
child
));
expect
(
isBuildDecorated
,
isTrue
);
expect
(
isDidChangeDependenciesDecorated
,
isFalse
);
await
tester
.
pumpWidget
(
Inherited
(
1
,
child:
child
));
expect
(
isBuildDecorated
,
isTrue
);
expect
(
isDidChangeDependenciesDecorated
,
isFalse
);
});
}
class
Decorate
extends
StatefulWidget
{
const
Decorate
({
Key
key
,
@required
this
.
didChangeDependencies
,
@required
this
.
build
})
:
assert
(
didChangeDependencies
!=
null
),
assert
(
build
!=
null
),
super
(
key:
key
);
final
void
Function
(
bool
isInBuild
)
didChangeDependencies
;
final
void
Function
(
bool
isInBuild
)
build
;
@override
_DecorateState
createState
()
=>
_DecorateState
();
@override
DecorateElement
createElement
()
=>
DecorateElement
(
this
);
}
class
DecorateElement
extends
StatefulElement
{
DecorateElement
(
Decorate
widget
):
super
(
widget
);
bool
isDecorated
=
false
;
@override
Widget
build
()
{
try
{
isDecorated
=
true
;
return
super
.
build
();
}
finally
{
isDecorated
=
false
;
}
}
}
class
_DecorateState
extends
State
<
Decorate
>
{
@override
void
didChangeDependencies
()
{
super
.
didChangeDependencies
();
widget
.
didChangeDependencies
.
call
((
context
as
DecorateElement
).
isDecorated
);
}
@override
Widget
build
(
covariant
DecorateElement
context
)
{
context
.
dependOnInheritedWidgetOfExactType
<
Inherited
>();
widget
.
build
.
call
(
context
.
isDecorated
);
return
Container
();
}
}
class
NullChildTest
extends
Widget
{
...
...
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