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
8aacc288
Commit
8aacc288
authored
Apr 13, 2017
by
xster
Committed by
GitHub
Apr 13, 2017
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Simplify change notifier toString and handle nulls (#9368)
parent
819bb539
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
9 deletions
+30
-9
change_notifier.dart
packages/flutter/lib/src/foundation/change_notifier.dart
+1
-9
change_notifier_test.dart
packages/flutter/test/foundation/change_notifier_test.dart
+29
-0
No files found.
packages/flutter/lib/src/foundation/change_notifier.dart
View file @
8aacc288
...
...
@@ -161,15 +161,7 @@ class _MergingListenable extends ChangeNotifier {
@override
String
toString
()
{
final
StringBuffer
buffer
=
new
StringBuffer
();
buffer
.
write
(
'Listenable.merge(['
);
for
(
int
i
=
0
;
i
<
_children
.
length
;
++
i
)
{
buffer
.
write
(
_children
[
i
].
toString
());
if
(
i
<
_children
.
length
-
1
)
buffer
.
write
(
', '
);
}
buffer
.
write
(
'])'
);
return
buffer
.
toString
();
return
'Listenable.merge([
${_children.join(", ")}
])'
;
}
}
...
...
packages/flutter/test/foundation/change_notifier_test.dart
View file @
8aacc288
...
...
@@ -206,4 +206,33 @@ void main() {
notifier
.
value
=
3.0
;
expect
(
log
,
isEmpty
);
});
test
(
'Listenable.merge toString'
,
()
{
final
TestNotifier
source1
=
new
TestNotifier
();
final
TestNotifier
source2
=
new
TestNotifier
();
ChangeNotifier
listenableUnderTest
=
new
Listenable
.
merge
(<
Listenable
>[]);
expect
(
listenableUnderTest
.
toString
(),
'Listenable.merge([])'
);
listenableUnderTest
=
new
Listenable
.
merge
(<
Listenable
>[
null
]);
expect
(
listenableUnderTest
.
toString
(),
'Listenable.merge([null])'
);
listenableUnderTest
=
new
Listenable
.
merge
(<
Listenable
>[
source1
]);
expect
(
listenableUnderTest
.
toString
(),
"Listenable.merge([Instance of 'TestNotifier'])"
,
);
listenableUnderTest
=
new
Listenable
.
merge
(<
Listenable
>[
source1
,
source2
]);
expect
(
listenableUnderTest
.
toString
(),
"Listenable.merge([Instance of 'TestNotifier', Instance of 'TestNotifier'])"
,
);
listenableUnderTest
=
new
Listenable
.
merge
(<
Listenable
>[
null
,
source2
]);
expect
(
listenableUnderTest
.
toString
(),
"Listenable.merge([null, Instance of 'TestNotifier'])"
,
);
});
}
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