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
b023a574
Unverified
Commit
b023a574
authored
Dec 11, 2018
by
Michael Goderbauer
Committed by
GitHub
Dec 11, 2018
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix debugPrint(null) to not crash (#24942)
parent
46599167
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
2 deletions
+16
-2
print.dart
packages/flutter/lib/src/foundation/print.dart
+4
-2
print_test.dart
packages/flutter/test/foundation/print_test.dart
+12
-0
No files found.
packages/flutter/lib/src/foundation/print.dart
View file @
b023a574
...
...
@@ -41,10 +41,11 @@ void debugPrintSynchronously(String message, { int wrapWidth }) {
/// Implementation of [debugPrint] that throttles messages. This avoids dropping
/// messages on platforms that rate-limit their logging (for example, Android).
void
debugPrintThrottled
(
String
message
,
{
int
wrapWidth
})
{
final
List
<
String
>
messageLines
=
message
?.
split
(
'
\n
'
)
??
<
String
>[
'null'
];
if
(
wrapWidth
!=
null
)
{
_debugPrintBuffer
.
addAll
(
message
.
split
(
'
\n
'
)
.
expand
<
String
>((
String
line
)
=>
debugWordWrap
(
line
,
wrapWidth
)));
_debugPrintBuffer
.
addAll
(
message
Lines
.
expand
<
String
>((
String
line
)
=>
debugWordWrap
(
line
,
wrapWidth
)));
}
else
{
_debugPrintBuffer
.
addAll
(
message
.
split
(
'
\n
'
)
);
_debugPrintBuffer
.
addAll
(
message
Lines
);
}
if
(!
_debugPrintScheduled
)
_debugPrintTask
();
...
...
@@ -87,6 +88,7 @@ Future<void> get debugPrintDone => _debugPrintCompleter?.future ?? Future<void>.
final
RegExp
_indentPattern
=
RegExp
(
'^ *(?:[-+*] |[0-9]+[.):] )?'
);
enum
_WordWrapParseMode
{
inSpace
,
inWord
,
atBreak
}
/// Wraps the given string at the given width.
///
/// Wrapping occurs at space characters (U+0020). Lines that start with an
...
...
packages/flutter/test/foundation/print_test.dart
View file @
b023a574
...
...
@@ -57,4 +57,16 @@ void main() {
expect
(
log
.
length
,
2
);
});
});
test
(
'debugPrint can print null'
,
()
{
expect
(
captureOutput
(()
{
debugPrintThrottled
(
null
);
}),
equals
(<
String
>[
'null'
]),
);
expect
(
captureOutput
(()
{
debugPrintThrottled
(
null
,
wrapWidth:
80
);
}),
equals
(<
String
>[
'null'
]),
);
});
}
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