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
68c96f10
Unverified
Commit
68c96f10
authored
Feb 09, 2021
by
Michael Goderbauer
Committed by
GitHub
Feb 09, 2021
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Revert "Fix/ValueListenableBuilder rebuilds (#72707)" (#75669)
This reverts commit
69882d96
.
parent
021311ed
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
1 addition
and
47 deletions
+1
-47
value_listenable_builder.dart
...ges/flutter/lib/src/widgets/value_listenable_builder.dart
+1
-3
value_listenable_builder_test.dart
...s/flutter/test/widgets/value_listenable_builder_test.dart
+0
-44
No files found.
packages/flutter/lib/src/widgets/value_listenable_builder.dart
View file @
68c96f10
...
...
@@ -179,9 +179,7 @@ class _ValueListenableBuilderState<T> extends State<ValueListenableBuilder<T>> {
}
void
_valueChanged
()
{
if
(
value
!=
widget
.
valueListenable
.
value
)
{
setState
(()
{
value
=
widget
.
valueListenable
.
value
;
});
}
setState
(()
{
value
=
widget
.
valueListenable
.
value
;
});
}
@override
...
...
packages/flutter/test/widgets/value_listenable_builder_test.dart
View file @
68c96f10
...
...
@@ -9,7 +9,6 @@ import 'package:flutter/widgets.dart';
void
main
(
)
{
late
SpyStringValueNotifier
valueListenable
;
late
Widget
textBuilderUnderTest
;
late
int
rebuildCount
;
Widget
builderForValueListenable
(
ValueListenable
<
String
?>
valueListenable
,
...
...
@@ -19,8 +18,6 @@ void main() {
child:
ValueListenableBuilder
<
String
?>(
valueListenable:
valueListenable
,
builder:
(
BuildContext
context
,
String
?
value
,
Widget
?
child
)
{
rebuildCount
+=
1
;
if
(
value
==
null
)
return
const
Placeholder
();
return
Text
(
value
);
...
...
@@ -32,7 +29,6 @@ void main() {
setUp
(()
{
valueListenable
=
SpyStringValueNotifier
(
null
);
textBuilderUnderTest
=
builderForValueListenable
(
valueListenable
);
rebuildCount
=
0
;
});
testWidgets
(
'Null value is ok'
,
(
WidgetTester
tester
)
async
{
...
...
@@ -62,46 +58,6 @@ void main() {
expect
(
find
.
text
(
'Dinesh'
),
findsOneWidget
);
});
testWidgets
(
'Widget does not rebuilds if value is the same'
,
(
WidgetTester
tester
)
async
{
const
Duration
duration
=
Duration
(
milliseconds:
100
);
final
AnimationController
controller
=
AnimationController
(
vsync:
const
TestVSync
(),
duration:
duration
,
)..
value
=
0
;
final
Animation
<
String
>
animation
=
TweenSequence
<
String
>(<
TweenSequenceItem
<
String
>>[
TweenSequenceItem
<
String
>(
tween:
ConstantTween
<
String
>(
'Gilfoyle'
),
weight:
1.0
),
TweenSequenceItem
<
String
>(
tween:
ConstantTween
<
String
>(
'Dinesh'
),
weight:
1.0
),
]).
animate
(
controller
);
final
Finder
finder1
=
find
.
text
(
'Gilfoyle'
);
final
Finder
finder2
=
find
.
text
(
'Dinesh'
);
await
tester
.
pumpWidget
(
builderForValueListenable
(
animation
));
await
tester
.
pump
();
expect
(
finder1
,
findsOneWidget
);
expect
(
finder2
,
findsNothing
);
expect
(
rebuildCount
,
equals
(
1
));
controller
.
value
=
0.3
;
await
tester
.
pump
();
expect
(
finder1
,
findsOneWidget
);
expect
(
finder2
,
findsNothing
);
expect
(
rebuildCount
,
equals
(
1
));
controller
.
animateTo
(
0.6
);
await
tester
.
pumpAndSettle
(
duration
);
expect
(
finder1
,
findsNothing
);
expect
(
finder2
,
findsOneWidget
);
expect
(
rebuildCount
,
equals
(
2
));
controller
.
forward
();
await
tester
.
pumpAndSettle
(
duration
);
expect
(
finder1
,
findsNothing
);
expect
(
finder2
,
findsOneWidget
);
expect
(
rebuildCount
,
equals
(
2
));
});
testWidgets
(
'Can change listenable'
,
(
WidgetTester
tester
)
async
{
await
tester
.
pumpWidget
(
textBuilderUnderTest
);
...
...
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