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
978a2e7b
Unverified
Commit
978a2e7b
authored
Jul 15, 2020
by
Alexandre Ardhuin
Committed by
GitHub
Jul 15, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
migrate foundation to nullsafety (#61188)
* migrate foundation to nullsafety * address review comments
parent
cb7770b3
Changes
32
Show whitespace changes
Inline
Side-by-side
Showing
32 changed files
with
453 additions
and
508 deletions
+453
-508
analysis_options.yaml
packages/flutter/analysis_options.yaml
+4
-0
foundation.dart
packages/flutter/lib/foundation.dart
+0
-2
_bitfield_io.dart
packages/flutter/lib/src/foundation/_bitfield_io.dart
+0
-2
_bitfield_web.dart
packages/flutter/lib/src/foundation/_bitfield_web.dart
+0
-2
_isolates_io.dart
packages/flutter/lib/src/foundation/_isolates_io.dart
+1
-3
_isolates_web.dart
packages/flutter/lib/src/foundation/_isolates_web.dart
+1
-3
_platform_io.dart
packages/flutter/lib/src/foundation/_platform_io.dart
+2
-4
_platform_web.dart
packages/flutter/lib/src/foundation/_platform_web.dart
+1
-3
annotations.dart
packages/flutter/lib/src/foundation/annotations.dart
+0
-2
assertions.dart
packages/flutter/lib/src/foundation/assertions.dart
+51
-53
basic_types.dart
packages/flutter/lib/src/foundation/basic_types.dart
+1
-3
binding.dart
packages/flutter/lib/src/foundation/binding.dart
+17
-19
bitfield.dart
packages/flutter/lib/src/foundation/bitfield.dart
+0
-2
change_notifier.dart
packages/flutter/lib/src/foundation/change_notifier.dart
+10
-12
collections.dart
packages/flutter/lib/src/foundation/collections.dart
+23
-25
consolidate_response.dart
...ages/flutter/lib/src/foundation/consolidate_response.dart
+10
-12
constants.dart
packages/flutter/lib/src/foundation/constants.dart
+0
-2
debug.dart
packages/flutter/lib/src/foundation/debug.dart
+9
-9
diagnostics.dart
packages/flutter/lib/src/foundation/diagnostics.dart
+227
-230
isolates.dart
packages/flutter/lib/src/foundation/isolates.dart
+1
-3
key.dart
packages/flutter/lib/src/foundation/key.dart
+0
-2
licenses.dart
packages/flutter/lib/src/foundation/licenses.dart
+7
-9
node.dart
packages/flutter/lib/src/foundation/node.dart
+7
-9
object.dart
packages/flutter/lib/src/foundation/object.dart
+1
-3
observer_list.dart
packages/flutter/lib/src/foundation/observer_list.dart
+6
-12
platform.dart
packages/flutter/lib/src/foundation/platform.dart
+1
-3
print.dart
packages/flutter/lib/src/foundation/print.dart
+9
-11
serialization.dart
packages/flutter/lib/src/foundation/serialization.dart
+29
-31
stack_frame.dart
packages/flutter/lib/src/foundation/stack_frame.dart
+27
-27
synchronous_future.dart
packages/flutter/lib/src/foundation/synchronous_future.dart
+6
-8
unicode.dart
packages/flutter/lib/src/foundation/unicode.dart
+0
-2
texture_test.dart
packages/flutter/test/widgets/texture_test.dart
+2
-0
No files found.
packages/flutter/analysis_options.yaml
View file @
978a2e7b
...
@@ -5,3 +5,7 @@ include: ../analysis_options.yaml
...
@@ -5,3 +5,7 @@ include: ../analysis_options.yaml
analyzer
:
analyzer
:
enable-experiment
:
enable-experiment
:
-
non-nullable
-
non-nullable
errors
:
always_require_non_null_named_parameters
:
false
# not needed with nnbd
void_checks
:
false
# https://github.com/dart-lang/linter/issues/2185
unnecessary_null_comparison
:
false
# https://github.com/dart-lang/language/issues/1018 , turned off until https://github.com/flutter/flutter/issues/61042
packages/flutter/lib/foundation.dart
View file @
978a2e7b
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
/// Core Flutter framework primitives.
/// Core Flutter framework primitives.
///
///
/// The features defined in this library are the lowest-level utility
/// The features defined in this library are the lowest-level utility
...
...
packages/flutter/lib/src/foundation/_bitfield_io.dart
View file @
978a2e7b
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'bitfield.dart'
as
bitfield
;
import
'bitfield.dart'
as
bitfield
;
/// The dart:io implementation of [bitfield.kMaxUnsignedSMI].
/// The dart:io implementation of [bitfield.kMaxUnsignedSMI].
...
...
packages/flutter/lib/src/foundation/_bitfield_web.dart
View file @
978a2e7b
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'bitfield.dart'
as
bitfield
;
import
'bitfield.dart'
as
bitfield
;
/// The dart:html implementation of [bitfield.kMaxUnsignedSMI].
/// The dart:html implementation of [bitfield.kMaxUnsignedSMI].
...
...
packages/flutter/lib/src/foundation/_isolates_io.dart
View file @
978a2e7b
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:async'
;
import
'dart:async'
;
import
'dart:developer'
;
import
'dart:developer'
;
import
'dart:isolate'
;
import
'dart:isolate'
;
...
@@ -13,7 +11,7 @@ import 'constants.dart';
...
@@ -13,7 +11,7 @@ import 'constants.dart';
import
'isolates.dart'
as
isolates
;
import
'isolates.dart'
as
isolates
;
/// The dart:io implementation of [isolate.compute].
/// The dart:io implementation of [isolate.compute].
Future
<
R
>
compute
<
Q
,
R
>(
isolates
.
ComputeCallback
<
Q
,
R
>
callback
,
Q
message
,
{
String
debugLabel
})
async
{
Future
<
R
>
compute
<
Q
,
R
>(
isolates
.
ComputeCallback
<
Q
,
R
>
callback
,
Q
message
,
{
String
?
debugLabel
})
async
{
debugLabel
??=
kReleaseMode
?
'compute'
:
callback
.
toString
();
debugLabel
??=
kReleaseMode
?
'compute'
:
callback
.
toString
();
final
Flow
flow
=
Flow
.
begin
();
final
Flow
flow
=
Flow
.
begin
();
Timeline
.
startSync
(
'
$debugLabel
: start'
,
flow:
flow
);
Timeline
.
startSync
(
'
$debugLabel
: start'
,
flow:
flow
);
...
...
packages/flutter/lib/src/foundation/_isolates_web.dart
View file @
978a2e7b
...
@@ -2,12 +2,10 @@
...
@@ -2,12 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'isolates.dart'
as
isolates
;
import
'isolates.dart'
as
isolates
;
/// The dart:html implementation of [isolate.compute].
/// The dart:html implementation of [isolate.compute].
Future
<
R
>
compute
<
Q
,
R
>(
isolates
.
ComputeCallback
<
Q
,
R
>
callback
,
Q
message
,
{
String
debugLabel
})
async
{
Future
<
R
>
compute
<
Q
,
R
>(
isolates
.
ComputeCallback
<
Q
,
R
>
callback
,
Q
message
,
{
String
?
debugLabel
})
async
{
// To avoid blocking the UI immediately for an expensive function call, we
// To avoid blocking the UI immediately for an expensive function call, we
// pump a single frame to allow the framework to complete the current set
// pump a single frame to allow the framework to complete the current set
// of work.
// of work.
...
...
packages/flutter/lib/src/foundation/_platform_io.dart
View file @
978a2e7b
...
@@ -2,15 +2,13 @@
...
@@ -2,15 +2,13 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:io'
;
import
'dart:io'
;
import
'assertions.dart'
;
import
'assertions.dart'
;
import
'platform.dart'
as
platform
;
import
'platform.dart'
as
platform
;
/// The dart:io implementation of [platform.defaultTargetPlatform].
/// The dart:io implementation of [platform.defaultTargetPlatform].
platform
.
TargetPlatform
get
defaultTargetPlatform
{
platform
.
TargetPlatform
get
defaultTargetPlatform
{
platform
.
TargetPlatform
result
;
platform
.
TargetPlatform
?
result
;
if
(
Platform
.
isAndroid
)
{
if
(
Platform
.
isAndroid
)
{
result
=
platform
.
TargetPlatform
.
android
;
result
=
platform
.
TargetPlatform
.
android
;
}
else
if
(
Platform
.
isIOS
)
{
}
else
if
(
Platform
.
isIOS
)
{
...
@@ -38,5 +36,5 @@ platform.TargetPlatform get defaultTargetPlatform {
...
@@ -38,5 +36,5 @@ platform.TargetPlatform get defaultTargetPlatform {
'Consider updating the list of TargetPlatforms to include this platform.'
'Consider updating the list of TargetPlatforms to include this platform.'
);
);
}
}
return
result
;
return
result
!
;
}
}
packages/flutter/lib/src/foundation/_platform_web.dart
View file @
978a2e7b
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:html'
as
html
;
import
'dart:html'
as
html
;
import
'platform.dart'
as
platform
;
import
'platform.dart'
as
platform
;
...
@@ -14,7 +12,7 @@ platform.TargetPlatform get defaultTargetPlatform {
...
@@ -14,7 +12,7 @@ platform.TargetPlatform get defaultTargetPlatform {
// platforms configuration for Flutter.
// platforms configuration for Flutter.
platform
.
TargetPlatform
result
=
_browserPlatform
();
platform
.
TargetPlatform
result
=
_browserPlatform
();
if
(
platform
.
debugDefaultTargetPlatformOverride
!=
null
)
if
(
platform
.
debugDefaultTargetPlatformOverride
!=
null
)
result
=
platform
.
debugDefaultTargetPlatformOverride
;
result
=
platform
.
debugDefaultTargetPlatformOverride
!
;
return
result
;
return
result
;
}
}
...
...
packages/flutter/lib/src/foundation/annotations.dart
View file @
978a2e7b
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
// Examples can assume:
// Examples can assume:
// class Cat { }
// class Cat { }
...
...
packages/flutter/lib/src/foundation/assertions.dart
View file @
978a2e7b
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:meta/meta.dart'
;
import
'package:meta/meta.dart'
;
import
'basic_types.dart'
;
import
'basic_types.dart'
;
...
@@ -46,9 +44,9 @@ class PartialStackFrame {
...
@@ -46,9 +44,9 @@ class PartialStackFrame {
/// Creates a new [PartialStackFrame] instance. All arguments are required and
/// Creates a new [PartialStackFrame] instance. All arguments are required and
/// must not be null.
/// must not be null.
const
PartialStackFrame
({
const
PartialStackFrame
({
@
required
this
.
package
,
required
this
.
package
,
@
required
this
.
className
,
required
this
.
className
,
@
required
this
.
method
,
required
this
.
method
,
})
:
assert
(
className
!=
null
),
})
:
assert
(
className
!=
null
),
assert
(
method
!=
null
),
assert
(
method
!=
null
),
assert
(
package
!=
null
);
assert
(
package
!=
null
);
...
@@ -102,7 +100,7 @@ abstract class StackFilter {
...
@@ -102,7 +100,7 @@ abstract class StackFilter {
/// `reasons`.
/// `reasons`.
///
///
/// To elide a frame or number of frames, set the string
/// To elide a frame or number of frames, set the string
void
filter
(
List
<
StackFrame
>
stackFrames
,
List
<
String
>
reasons
);
void
filter
(
List
<
StackFrame
>
stackFrames
,
List
<
String
?
>
reasons
);
}
}
...
@@ -120,8 +118,8 @@ class RepetitiveStackFrameFilter extends StackFilter {
...
@@ -120,8 +118,8 @@ class RepetitiveStackFrameFilter extends StackFilter {
/// Creates a new RepetitiveStackFrameFilter. All parameters are required and must not be
/// Creates a new RepetitiveStackFrameFilter. All parameters are required and must not be
/// null.
/// null.
const
RepetitiveStackFrameFilter
({
const
RepetitiveStackFrameFilter
({
@
required
this
.
frames
,
required
this
.
frames
,
@
required
this
.
replacement
,
required
this
.
replacement
,
})
:
assert
(
frames
!=
null
),
})
:
assert
(
frames
!=
null
),
assert
(
replacement
!=
null
);
assert
(
replacement
!=
null
);
...
@@ -141,7 +139,7 @@ class RepetitiveStackFrameFilter extends StackFilter {
...
@@ -141,7 +139,7 @@ class RepetitiveStackFrameFilter extends StackFilter {
List
<
String
>
get
_replacements
=>
List
<
String
>.
filled
(
numFrames
,
replacement
);
List
<
String
>
get
_replacements
=>
List
<
String
>.
filled
(
numFrames
,
replacement
);
@override
@override
void
filter
(
List
<
StackFrame
>
stackFrames
,
List
<
String
>
reasons
)
{
void
filter
(
List
<
StackFrame
>
stackFrames
,
List
<
String
?
>
reasons
)
{
for
(
int
index
=
0
;
index
<
stackFrames
.
length
-
numFrames
;
index
+=
1
)
{
for
(
int
index
=
0
;
index
<
stackFrames
.
length
-
numFrames
;
index
+=
1
)
{
if
(
_matchesFrames
(
stackFrames
.
skip
(
index
).
take
(
numFrames
).
toList
()))
{
if
(
_matchesFrames
(
stackFrames
.
skip
(
index
).
take
(
numFrames
).
toList
()))
{
reasons
.
setRange
(
index
,
index
+
numFrames
,
_replacements
);
reasons
.
setRange
(
index
,
index
+
numFrames
,
_replacements
);
...
@@ -222,8 +220,12 @@ abstract class _ErrorDiagnostic extends DiagnosticsProperty<List<Object>> {
...
@@ -222,8 +220,12 @@ abstract class _ErrorDiagnostic extends DiagnosticsProperty<List<Object>> {
level:
level
,
level:
level
,
);
);
@override
List
<
Object
>
get
value
=>
super
.
value
!;
@override
@override
String
valueToString
({
TextTreeConfiguration
parentConfiguration
})
{
String
valueToString
({
TextTreeConfiguration
?
parentConfiguration
})
{
return
value
.
join
(
''
);
return
value
.
join
(
''
);
}
}
}
}
...
@@ -400,13 +402,13 @@ class FlutterErrorDetails with Diagnosticable {
...
@@ -400,13 +402,13 @@ class FlutterErrorDetails with Diagnosticable {
/// Creates a copy of the error details but with the given fields replaced
/// Creates a copy of the error details but with the given fields replaced
/// with new values.
/// with new values.
FlutterErrorDetails
copyWith
({
FlutterErrorDetails
copyWith
({
DiagnosticsNode
context
,
DiagnosticsNode
?
context
,
dynamic
exception
,
dynamic
exception
,
InformationCollector
informationCollector
,
InformationCollector
?
informationCollector
,
String
library
,
String
?
library
,
bool
silent
,
bool
?
silent
,
StackTrace
stack
,
StackTrace
?
stack
,
IterableFilter
<
String
>
stackFilter
,
IterableFilter
<
String
>
?
stackFilter
,
})
{
})
{
return
FlutterErrorDetails
(
return
FlutterErrorDetails
(
context:
context
??
this
.
context
,
context:
context
??
this
.
context
,
...
@@ -448,12 +450,12 @@ class FlutterErrorDetails with Diagnosticable {
...
@@ -448,12 +450,12 @@ class FlutterErrorDetails with Diagnosticable {
/// callback, then [FlutterError.defaultStackFilter] is used instead. That
/// callback, then [FlutterError.defaultStackFilter] is used instead. That
/// function expects the stack to be in the format used by
/// function expects the stack to be in the format used by
/// [StackTrace.toString].
/// [StackTrace.toString].
final
StackTrace
stack
;
final
StackTrace
?
stack
;
/// A human-readable brief name describing the library that caught the error
/// A human-readable brief name describing the library that caught the error
/// message. This is used by the default error handler in the header dumped to
/// message. This is used by the default error handler in the header dumped to
/// the console.
/// the console.
final
String
library
;
final
String
?
library
;
/// A [DiagnosticsNode] that provides a human-readable description of where
/// A [DiagnosticsNode] that provides a human-readable description of where
/// the error was caught (as opposed to where it was thrown).
/// the error was caught (as opposed to where it was thrown).
...
@@ -494,7 +496,7 @@ class FlutterErrorDetails with Diagnosticable {
...
@@ -494,7 +496,7 @@ class FlutterErrorDetails with Diagnosticable {
/// applicable.
/// applicable.
/// * [FlutterError], which is the most common place to use
/// * [FlutterError], which is the most common place to use
/// [FlutterErrorDetails].
/// [FlutterErrorDetails].
final
DiagnosticsNode
context
;
final
DiagnosticsNode
?
context
;
/// A callback which filters the [stack] trace. Receives an iterable of
/// A callback which filters the [stack] trace. Receives an iterable of
/// strings representing the frames encoded in the way that
/// strings representing the frames encoded in the way that
...
@@ -510,7 +512,7 @@ class FlutterErrorDetails with Diagnosticable {
...
@@ -510,7 +512,7 @@ class FlutterErrorDetails with Diagnosticable {
/// that function, however, does not always follow this format.
/// that function, however, does not always follow this format.
///
///
/// This won't be called if [stack] is null.
/// This won't be called if [stack] is null.
final
IterableFilter
<
String
>
stackFilter
;
final
IterableFilter
<
String
>
?
stackFilter
;
/// A callback which, when called with a [StringBuffer] will write to that buffer
/// A callback which, when called with a [StringBuffer] will write to that buffer
/// information that could help with debugging the problem.
/// information that could help with debugging the problem.
...
@@ -520,7 +522,7 @@ class FlutterErrorDetails with Diagnosticable {
...
@@ -520,7 +522,7 @@ class FlutterErrorDetails with Diagnosticable {
///
///
/// The text written to the information argument may contain newlines but should
/// The text written to the information argument may contain newlines but should
/// not end with a newline.
/// not end with a newline.
final
InformationCollector
informationCollector
;
final
InformationCollector
?
informationCollector
;
/// Whether this error should be ignored by the default error reporting
/// Whether this error should be ignored by the default error reporting
/// behavior in release mode.
/// behavior in release mode.
...
@@ -544,13 +546,13 @@ class FlutterErrorDetails with Diagnosticable {
...
@@ -544,13 +546,13 @@ class FlutterErrorDetails with Diagnosticable {
/// prettier, to handle exceptions that stringify to empty strings, to handle
/// prettier, to handle exceptions that stringify to empty strings, to handle
/// objects that don't inherit from [Exception] or [Error], and so forth.
/// objects that don't inherit from [Exception] or [Error], and so forth.
String
exceptionAsString
()
{
String
exceptionAsString
()
{
String
longMessage
;
String
?
longMessage
;
if
(
exception
is
AssertionError
)
{
if
(
exception
is
AssertionError
)
{
// Regular _AssertionErrors thrown by assert() put the message last, after
// Regular _AssertionErrors thrown by assert() put the message last, after
// some code snippets. This leads to ugly messages. To avoid this, we move
// some code snippets. This leads to ugly messages. To avoid this, we move
// the assertion message up to before the code snippets, separated by a
// the assertion message up to before the code snippets, separated by a
// newline, if we recognize that format is being used.
// newline, if we recognize that format is being used.
final
Object
message
=
exception
.
message
;
final
Object
?
message
=
exception
.
message
;
final
String
fullMessage
=
exception
.
toString
();
final
String
fullMessage
=
exception
.
toString
();
if
(
message
is
String
&&
message
!=
fullMessage
)
{
if
(
message
is
String
&&
message
!=
fullMessage
)
{
if
(
fullMessage
.
length
>
message
.
length
)
{
if
(
fullMessage
.
length
>
message
.
length
)
{
...
@@ -583,7 +585,7 @@ class FlutterErrorDetails with Diagnosticable {
...
@@ -583,7 +585,7 @@ class FlutterErrorDetails with Diagnosticable {
return
longMessage
;
return
longMessage
;
}
}
Diagnosticable
_exceptionToDiagnosticable
()
{
Diagnosticable
?
_exceptionToDiagnosticable
()
{
if
(
exception
is
FlutterError
)
{
if
(
exception
is
FlutterError
)
{
return
exception
as
FlutterError
;
return
exception
as
FlutterError
;
}
}
...
@@ -606,12 +608,12 @@ class FlutterErrorDetails with Diagnosticable {
...
@@ -606,12 +608,12 @@ class FlutterErrorDetails with Diagnosticable {
if
(
kReleaseMode
)
{
if
(
kReleaseMode
)
{
return
DiagnosticsNode
.
message
(
formatException
());
return
DiagnosticsNode
.
message
(
formatException
());
}
}
final
Diagnosticable
diagnosticable
=
_exceptionToDiagnosticable
();
final
Diagnosticable
?
diagnosticable
=
_exceptionToDiagnosticable
();
DiagnosticsNode
summary
;
DiagnosticsNode
?
summary
;
if
(
diagnosticable
!=
null
)
{
if
(
diagnosticable
!=
null
)
{
final
DiagnosticPropertiesBuilder
builder
=
DiagnosticPropertiesBuilder
();
final
DiagnosticPropertiesBuilder
builder
=
DiagnosticPropertiesBuilder
();
debugFillProperties
(
builder
);
debugFillProperties
(
builder
);
summary
=
builder
.
properties
.
firstWhere
((
DiagnosticsNode
node
)
=>
node
.
level
==
DiagnosticLevel
.
summary
,
orElse:
()
=>
null
);
summary
=
builder
.
properties
.
cast
<
DiagnosticsNode
?>().
firstWhere
((
DiagnosticsNode
?
node
)
=>
node
!
.
level
==
DiagnosticLevel
.
summary
,
orElse:
()
=>
null
);
}
}
return
summary
??
ErrorSummary
(
formatException
());
return
summary
??
ErrorSummary
(
formatException
());
}
}
...
@@ -620,7 +622,7 @@ class FlutterErrorDetails with Diagnosticable {
...
@@ -620,7 +622,7 @@ class FlutterErrorDetails with Diagnosticable {
void
debugFillProperties
(
DiagnosticPropertiesBuilder
properties
)
{
void
debugFillProperties
(
DiagnosticPropertiesBuilder
properties
)
{
super
.
debugFillProperties
(
properties
);
super
.
debugFillProperties
(
properties
);
final
DiagnosticsNode
verb
=
ErrorDescription
(
'thrown
${ context != null ? ErrorDescription(" $context") : ""}
'
);
final
DiagnosticsNode
verb
=
ErrorDescription
(
'thrown
${ context != null ? ErrorDescription(" $context") : ""}
'
);
final
Diagnosticable
diagnosticable
=
_exceptionToDiagnosticable
();
final
Diagnosticable
?
diagnosticable
=
_exceptionToDiagnosticable
();
if
(
exception
is
NullThrownError
)
{
if
(
exception
is
NullThrownError
)
{
properties
.
add
(
ErrorDescription
(
'The null value was
$verb
.'
));
properties
.
add
(
ErrorDescription
(
'The null value was
$verb
.'
));
}
else
if
(
exception
is
num
)
{
}
else
if
(
exception
is
num
)
{
...
@@ -659,7 +661,7 @@ class FlutterErrorDetails with Diagnosticable {
...
@@ -659,7 +661,7 @@ class FlutterErrorDetails with Diagnosticable {
// If not: Error is in user code (user violated assertion in framework).
// If not: Error is in user code (user violated assertion in framework).
// If so: Error is in Framework. We either need an assertion higher up
// If so: Error is in Framework. We either need an assertion higher up
// in the stack, or we've violated our own assertions.
// in the stack, or we've violated our own assertions.
final
List
<
StackFrame
>
stackFrames
=
StackFrame
.
fromStackTrace
(
FlutterError
.
demangleStackTrace
(
stack
))
final
List
<
StackFrame
>
stackFrames
=
StackFrame
.
fromStackTrace
(
FlutterError
.
demangleStackTrace
(
stack
!
))
.
skipWhile
((
StackFrame
frame
)
=>
frame
.
packageScheme
==
'dart'
)
.
skipWhile
((
StackFrame
frame
)
=>
frame
.
packageScheme
==
'dart'
)
.
toList
();
.
toList
();
final
bool
ourFault
=
stackFrames
.
length
>=
2
final
bool
ourFault
=
stackFrames
.
length
>=
2
...
@@ -677,11 +679,11 @@ class FlutterErrorDetails with Diagnosticable {
...
@@ -677,11 +679,11 @@ class FlutterErrorDetails with Diagnosticable {
}
}
}
}
properties
.
add
(
ErrorSpacer
());
properties
.
add
(
ErrorSpacer
());
properties
.
add
(
DiagnosticsStackTrace
(
'When the exception was thrown, this was the stack'
,
stack
,
stackFilter:
stackFilter
));
properties
.
add
(
DiagnosticsStackTrace
(
'When the exception was thrown, this was the stack'
,
stack
!
,
stackFilter:
stackFilter
));
}
}
if
(
informationCollector
!=
null
)
{
if
(
informationCollector
!=
null
)
{
properties
.
add
(
ErrorSpacer
());
properties
.
add
(
ErrorSpacer
());
informationCollector
().
forEach
(
properties
.
add
);
informationCollector
!
().
forEach
(
properties
.
add
);
}
}
}
}
...
@@ -696,7 +698,7 @@ class FlutterErrorDetails with Diagnosticable {
...
@@ -696,7 +698,7 @@ class FlutterErrorDetails with Diagnosticable {
}
}
@override
@override
DiagnosticsNode
toDiagnosticsNode
({
String
name
,
DiagnosticsTreeStyle
style
})
{
DiagnosticsNode
toDiagnosticsNode
({
String
?
name
,
DiagnosticsTreeStyle
?
style
})
{
return
_FlutterErrorDetailsNode
(
return
_FlutterErrorDetailsNode
(
name:
name
,
name:
name
,
value:
this
,
value:
this
,
...
@@ -866,9 +868,6 @@ class FlutterError extends Error with DiagnosticableTreeMixin implements Asserti
...
@@ -866,9 +868,6 @@ class FlutterError extends Error with DiagnosticableTreeMixin implements Asserti
///
///
/// If the error handler throws an exception, it will not be caught by the
/// If the error handler throws an exception, it will not be caught by the
/// Flutter framework.
/// Flutter framework.
///
/// Set this to null to silently catch and ignore errors. This is not
/// recommended.
static
FlutterExceptionHandler
onError
=
(
FlutterErrorDetails
details
)
=>
presentError
(
details
);
static
FlutterExceptionHandler
onError
=
(
FlutterErrorDetails
details
)
=>
presentError
(
details
);
/// Called by the Flutter framework before attempting to parse a [StackTrace].
/// Called by the Flutter framework before attempting to parse a [StackTrace].
...
@@ -1005,17 +1004,17 @@ class FlutterError extends Error with DiagnosticableTreeMixin implements Asserti
...
@@ -1005,17 +1004,17 @@ class FlutterError extends Error with DiagnosticableTreeMixin implements Asserti
final
String
package
=
'
${frame.packageScheme}
:
${frame.package}
'
;
final
String
package
=
'
${frame.packageScheme}
:
${frame.package}
'
;
if
(
removedPackagesAndClasses
.
containsKey
(
className
))
{
if
(
removedPackagesAndClasses
.
containsKey
(
className
))
{
skipped
+=
1
;
skipped
+=
1
;
removedPackagesAndClasses
[
className
]
+=
1
;
removedPackagesAndClasses
.
update
(
className
,
(
int
value
)
=>
value
+
1
)
;
parsedFrames
.
removeAt
(
index
);
parsedFrames
.
removeAt
(
index
);
index
-=
1
;
index
-=
1
;
}
else
if
(
removedPackagesAndClasses
.
containsKey
(
package
))
{
}
else
if
(
removedPackagesAndClasses
.
containsKey
(
package
))
{
skipped
+=
1
;
skipped
+=
1
;
removedPackagesAndClasses
[
package
]
+=
1
;
removedPackagesAndClasses
.
update
(
package
,
(
int
value
)
=>
value
+
1
)
;
parsedFrames
.
removeAt
(
index
);
parsedFrames
.
removeAt
(
index
);
index
-=
1
;
index
-=
1
;
}
}
}
}
final
List
<
String
>
reasons
=
List
<
String
>(
parsedFrames
.
length
);
final
List
<
String
?>
reasons
=
List
<
String
?>.
filled
(
parsedFrames
.
length
,
null
,
growable:
false
);
for
(
final
StackFilter
filter
in
_stackFilters
)
{
for
(
final
StackFilter
filter
in
_stackFilters
)
{
filter
.
filter
(
parsedFrames
,
reasons
);
filter
.
filter
(
parsedFrames
,
reasons
);
}
}
...
@@ -1062,7 +1061,7 @@ class FlutterError extends Error with DiagnosticableTreeMixin implements Asserti
...
@@ -1062,7 +1061,7 @@ class FlutterError extends Error with DiagnosticableTreeMixin implements Asserti
@override
@override
void
debugFillProperties
(
DiagnosticPropertiesBuilder
properties
)
{
void
debugFillProperties
(
DiagnosticPropertiesBuilder
properties
)
{
diagnostics
?
.
forEach
(
properties
.
add
);
diagnostics
.
forEach
(
properties
.
add
);
}
}
@override
@override
...
@@ -1079,11 +1078,10 @@ class FlutterError extends Error with DiagnosticableTreeMixin implements Asserti
...
@@ -1079,11 +1078,10 @@ class FlutterError extends Error with DiagnosticableTreeMixin implements Asserti
return
diagnostics
.
map
((
DiagnosticsNode
node
)
=>
renderer
.
render
(
node
).
trimRight
()).
join
(
'
\n
'
);
return
diagnostics
.
map
((
DiagnosticsNode
node
)
=>
renderer
.
render
(
node
).
trimRight
()).
join
(
'
\n
'
);
}
}
/// Calls [onError] with the given details
, unless it is null
.
/// Calls [onError] with the given details.
static
void
reportError
(
FlutterErrorDetails
details
)
{
static
void
reportError
(
FlutterErrorDetails
details
)
{
assert
(
details
!=
null
);
assert
(
details
!=
null
);
assert
(
details
.
exception
!=
null
);
assert
(
details
.
exception
!=
null
);
if
(
onError
!=
null
)
onError
(
details
);
onError
(
details
);
}
}
}
}
...
@@ -1099,7 +1097,7 @@ class FlutterError extends Error with DiagnosticableTreeMixin implements Asserti
...
@@ -1099,7 +1097,7 @@ class FlutterError extends Error with DiagnosticableTreeMixin implements Asserti
/// included.
/// included.
///
///
/// The `label` argument, if present, will be printed before the stack.
/// The `label` argument, if present, will be printed before the stack.
void
debugPrintStack
(
{
StackTrace
stackTrace
,
String
label
,
int
maxFrames
})
{
void
debugPrintStack
(
{
StackTrace
?
stackTrace
,
String
?
label
,
int
?
maxFrames
})
{
if
(
label
!=
null
)
if
(
label
!=
null
)
debugPrint
(
label
);
debugPrint
(
label
);
if
(
stackTrace
==
null
)
{
if
(
stackTrace
==
null
)
{
...
@@ -1136,8 +1134,8 @@ class DiagnosticsStackTrace extends DiagnosticsBlock {
...
@@ -1136,8 +1134,8 @@ class DiagnosticsStackTrace extends DiagnosticsBlock {
/// [showSeparator] indicates whether to include a ':' after the [name].
/// [showSeparator] indicates whether to include a ':' after the [name].
DiagnosticsStackTrace
(
DiagnosticsStackTrace
(
String
name
,
String
name
,
StackTrace
stack
,
{
StackTrace
?
stack
,
{
IterableFilter
<
String
>
stackFilter
,
IterableFilter
<
String
>
?
stackFilter
,
bool
showSeparator
=
true
,
bool
showSeparator
=
true
,
})
:
super
(
})
:
super
(
name:
name
,
name:
name
,
...
@@ -1151,7 +1149,7 @@ class DiagnosticsStackTrace extends DiagnosticsBlock {
...
@@ -1151,7 +1149,7 @@ class DiagnosticsStackTrace extends DiagnosticsBlock {
/// Creates a diagnostic describing a single frame from a StackTrace.
/// Creates a diagnostic describing a single frame from a StackTrace.
DiagnosticsStackTrace
.
singleFrame
(
DiagnosticsStackTrace
.
singleFrame
(
String
name
,
{
String
name
,
{
@
required
String
frame
,
required
String
frame
,
bool
showSeparator
=
true
,
bool
showSeparator
=
true
,
})
:
super
(
})
:
super
(
name:
name
,
name:
name
,
...
@@ -1161,8 +1159,8 @@ class DiagnosticsStackTrace extends DiagnosticsBlock {
...
@@ -1161,8 +1159,8 @@ class DiagnosticsStackTrace extends DiagnosticsBlock {
);
);
static
List
<
DiagnosticsNode
>
_applyStackFilter
(
static
List
<
DiagnosticsNode
>
_applyStackFilter
(
StackTrace
stack
,
StackTrace
?
stack
,
IterableFilter
<
String
>
stackFilter
,
IterableFilter
<
String
>
?
stackFilter
,
)
{
)
{
if
(
stack
==
null
)
if
(
stack
==
null
)
return
<
DiagnosticsNode
>[];
return
<
DiagnosticsNode
>[];
...
@@ -1178,9 +1176,9 @@ class DiagnosticsStackTrace extends DiagnosticsBlock {
...
@@ -1178,9 +1176,9 @@ class DiagnosticsStackTrace extends DiagnosticsBlock {
class
_FlutterErrorDetailsNode
extends
DiagnosticableNode
<
FlutterErrorDetails
>
{
class
_FlutterErrorDetailsNode
extends
DiagnosticableNode
<
FlutterErrorDetails
>
{
_FlutterErrorDetailsNode
({
_FlutterErrorDetailsNode
({
String
name
,
String
?
name
,
@
required
FlutterErrorDetails
value
,
required
FlutterErrorDetails
value
,
@required
DiagnosticsTreeStyle
style
,
required
DiagnosticsTreeStyle
?
style
,
})
:
super
(
})
:
super
(
name:
name
,
name:
name
,
value:
value
,
value:
value
,
...
@@ -1188,8 +1186,8 @@ class _FlutterErrorDetailsNode extends DiagnosticableNode<FlutterErrorDetails> {
...
@@ -1188,8 +1186,8 @@ class _FlutterErrorDetailsNode extends DiagnosticableNode<FlutterErrorDetails> {
);
);
@override
@override
DiagnosticPropertiesBuilder
get
builder
{
DiagnosticPropertiesBuilder
?
get
builder
{
final
DiagnosticPropertiesBuilder
builder
=
super
.
builder
;
final
DiagnosticPropertiesBuilder
?
builder
=
super
.
builder
;
if
(
builder
==
null
){
if
(
builder
==
null
){
return
null
;
return
null
;
}
}
...
...
packages/flutter/lib/src/foundation/basic_types.dart
View file @
978a2e7b
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:async'
;
import
'dart:async'
;
import
'dart:collection'
;
import
'dart:collection'
;
...
@@ -207,7 +205,7 @@ class _LazyListIterator<E> implements Iterator<E> {
...
@@ -207,7 +205,7 @@ class _LazyListIterator<E> implements Iterator<E> {
E
get
current
{
E
get
current
{
assert
(
_index
>=
0
);
// called "current" before "moveNext()"
assert
(
_index
>=
0
);
// called "current" before "moveNext()"
if
(
_index
<
0
||
_index
==
_owner
.
_results
.
length
)
if
(
_index
<
0
||
_index
==
_owner
.
_results
.
length
)
return
null
;
throw
StateError
(
'current can not be call after moveNext has returned false'
)
;
return
_owner
.
_results
[
_index
];
return
_owner
.
_results
[
_index
];
}
}
...
...
packages/flutter/lib/src/foundation/binding.dart
View file @
978a2e7b
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:async'
;
import
'dart:async'
;
import
'dart:convert'
show
json
;
import
'dart:convert'
show
json
;
import
'dart:developer'
as
developer
;
import
'dart:developer'
as
developer
;
...
@@ -316,8 +314,8 @@ abstract class BindingBase {
...
@@ -316,8 +314,8 @@ abstract class BindingBase {
/// {@macro flutter.foundation.bindingBase.registerServiceExtension}
/// {@macro flutter.foundation.bindingBase.registerServiceExtension}
@protected
@protected
void
registerSignalServiceExtension
({
void
registerSignalServiceExtension
({
@
required
String
name
,
required
String
name
,
@
required
AsyncCallback
callback
,
required
AsyncCallback
callback
,
})
{
})
{
assert
(
name
!=
null
);
assert
(
name
!=
null
);
assert
(
callback
!=
null
);
assert
(
callback
!=
null
);
...
@@ -346,9 +344,9 @@ abstract class BindingBase {
...
@@ -346,9 +344,9 @@ abstract class BindingBase {
/// {@macro flutter.foundation.bindingBase.registerServiceExtension}
/// {@macro flutter.foundation.bindingBase.registerServiceExtension}
@protected
@protected
void
registerBoolServiceExtension
({
void
registerBoolServiceExtension
({
@
required
String
name
,
required
String
name
,
@
required
AsyncValueGetter
<
bool
>
getter
,
required
AsyncValueGetter
<
bool
>
getter
,
@
required
AsyncValueSetter
<
bool
>
setter
,
required
AsyncValueSetter
<
bool
>
setter
,
})
{
})
{
assert
(
name
!=
null
);
assert
(
name
!=
null
);
assert
(
getter
!=
null
);
assert
(
getter
!=
null
);
...
@@ -380,9 +378,9 @@ abstract class BindingBase {
...
@@ -380,9 +378,9 @@ abstract class BindingBase {
/// {@macro flutter.foundation.bindingBase.registerServiceExtension}
/// {@macro flutter.foundation.bindingBase.registerServiceExtension}
@protected
@protected
void
registerNumericServiceExtension
({
void
registerNumericServiceExtension
({
@
required
String
name
,
required
String
name
,
@
required
AsyncValueGetter
<
double
>
getter
,
required
AsyncValueGetter
<
double
>
getter
,
@
required
AsyncValueSetter
<
double
>
setter
,
required
AsyncValueSetter
<
double
>
setter
,
})
{
})
{
assert
(
name
!=
null
);
assert
(
name
!=
null
);
assert
(
getter
!=
null
);
assert
(
getter
!=
null
);
...
@@ -391,7 +389,7 @@ abstract class BindingBase {
...
@@ -391,7 +389,7 @@ abstract class BindingBase {
name:
name
,
name:
name
,
callback:
(
Map
<
String
,
String
>
parameters
)
async
{
callback:
(
Map
<
String
,
String
>
parameters
)
async
{
if
(
parameters
.
containsKey
(
name
))
{
if
(
parameters
.
containsKey
(
name
))
{
await
setter
(
double
.
parse
(
parameters
[
name
]));
await
setter
(
double
.
parse
(
parameters
[
name
]
!
));
_postExtensionStateChangedEvent
(
name
,
(
await
getter
()).
toString
());
_postExtensionStateChangedEvent
(
name
,
(
await
getter
()).
toString
());
}
}
return
<
String
,
dynamic
>{
name:
(
await
getter
()).
toString
()};
return
<
String
,
dynamic
>{
name:
(
await
getter
()).
toString
()};
...
@@ -442,9 +440,9 @@ abstract class BindingBase {
...
@@ -442,9 +440,9 @@ abstract class BindingBase {
/// {@macro flutter.foundation.bindingBase.registerServiceExtension}
/// {@macro flutter.foundation.bindingBase.registerServiceExtension}
@protected
@protected
void
registerStringServiceExtension
({
void
registerStringServiceExtension
({
@
required
String
name
,
required
String
name
,
@
required
AsyncValueGetter
<
String
>
getter
,
required
AsyncValueGetter
<
String
>
getter
,
@
required
AsyncValueSetter
<
String
>
setter
,
required
AsyncValueSetter
<
String
>
setter
,
})
{
})
{
assert
(
name
!=
null
);
assert
(
name
!=
null
);
assert
(
getter
!=
null
);
assert
(
getter
!=
null
);
...
@@ -453,7 +451,7 @@ abstract class BindingBase {
...
@@ -453,7 +451,7 @@ abstract class BindingBase {
name:
name
,
name:
name
,
callback:
(
Map
<
String
,
String
>
parameters
)
async
{
callback:
(
Map
<
String
,
String
>
parameters
)
async
{
if
(
parameters
.
containsKey
(
'value'
))
{
if
(
parameters
.
containsKey
(
'value'
))
{
await
setter
(
parameters
[
'value'
]);
await
setter
(
parameters
[
'value'
]
!
);
_postExtensionStateChangedEvent
(
name
,
await
getter
());
_postExtensionStateChangedEvent
(
name
,
await
getter
());
}
}
return
<
String
,
dynamic
>{
'value'
:
await
getter
()};
return
<
String
,
dynamic
>{
'value'
:
await
getter
()};
...
@@ -514,8 +512,8 @@ abstract class BindingBase {
...
@@ -514,8 +512,8 @@ abstract class BindingBase {
/// {@endtemplate}
/// {@endtemplate}
@protected
@protected
void
registerServiceExtension
({
void
registerServiceExtension
({
@
required
String
name
,
required
String
name
,
@
required
ServiceExtensionCallback
callback
,
required
ServiceExtensionCallback
callback
,
})
{
})
{
assert
(
name
!=
null
);
assert
(
name
!=
null
);
assert
(
callback
!=
null
);
assert
(
callback
!=
null
);
...
@@ -543,8 +541,8 @@ abstract class BindingBase {
...
@@ -543,8 +541,8 @@ abstract class BindingBase {
});
});
dynamic
caughtException
;
dynamic
caughtException
;
StackTrace
caughtStack
;
StackTrace
?
caughtStack
;
Map
<
String
,
dynamic
>
result
;
late
Map
<
String
,
dynamic
>
result
;
try
{
try
{
result
=
await
callback
(
parameters
);
result
=
await
callback
(
parameters
);
}
catch
(
exception
,
stack
)
{
}
catch
(
exception
,
stack
)
{
...
...
packages/flutter/lib/src/foundation/bitfield.dart
View file @
978a2e7b
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'_bitfield_io.dart'
import
'_bitfield_io.dart'
if
(
dart
.
library
.
html
)
'_bitfield_web.dart'
as
_bitfield
;
if
(
dart
.
library
.
html
)
'_bitfield_web.dart'
as
_bitfield
;
...
...
packages/flutter/lib/src/foundation/change_notifier.dart
View file @
978a2e7b
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:meta/meta.dart'
;
import
'package:meta/meta.dart'
;
import
'assertions.dart'
;
import
'assertions.dart'
;
...
@@ -65,7 +63,7 @@ abstract class Listenable {
...
@@ -65,7 +63,7 @@ abstract class Listenable {
/// will lead to memory leaks or exceptions.
/// will lead to memory leaks or exceptions.
///
///
/// The list may contain nulls; they are ignored.
/// The list may contain nulls; they are ignored.
factory
Listenable
.
merge
(
List
<
Listenable
>
listenables
)
=
_MergingListenable
;
factory
Listenable
.
merge
(
List
<
Listenable
?
>
listenables
)
=
_MergingListenable
;
/// Register a closure to be called when the object notifies its listeners.
/// Register a closure to be called when the object notifies its listeners.
void
addListener
(
VoidCallback
listener
);
void
addListener
(
VoidCallback
listener
);
...
@@ -100,7 +98,7 @@ abstract class ValueListenable<T> extends Listenable {
...
@@ -100,7 +98,7 @@ abstract class ValueListenable<T> extends Listenable {
///
///
/// * [ValueNotifier], which is a [ChangeNotifier] that wraps a single value.
/// * [ValueNotifier], which is a [ChangeNotifier] that wraps a single value.
class
ChangeNotifier
implements
Listenable
{
class
ChangeNotifier
implements
Listenable
{
ObserverList
<
VoidCallback
>
_listeners
=
ObserverList
<
VoidCallback
>();
ObserverList
<
VoidCallback
>
?
_listeners
=
ObserverList
<
VoidCallback
>();
bool
_debugAssertNotDisposed
()
{
bool
_debugAssertNotDisposed
()
{
assert
(()
{
assert
(()
{
...
@@ -133,7 +131,7 @@ class ChangeNotifier implements Listenable {
...
@@ -133,7 +131,7 @@ class ChangeNotifier implements Listenable {
@protected
@protected
bool
get
hasListeners
{
bool
get
hasListeners
{
assert
(
_debugAssertNotDisposed
());
assert
(
_debugAssertNotDisposed
());
return
_listeners
.
isNotEmpty
;
return
_listeners
!
.
isNotEmpty
;
}
}
/// Register a closure to be called when the object changes.
/// Register a closure to be called when the object changes.
...
@@ -142,7 +140,7 @@ class ChangeNotifier implements Listenable {
...
@@ -142,7 +140,7 @@ class ChangeNotifier implements Listenable {
@override
@override
void
addListener
(
VoidCallback
listener
)
{
void
addListener
(
VoidCallback
listener
)
{
assert
(
_debugAssertNotDisposed
());
assert
(
_debugAssertNotDisposed
());
_listeners
.
add
(
listener
);
_listeners
!
.
add
(
listener
);
}
}
/// Remove a previously registered closure from the list of closures that are
/// Remove a previously registered closure from the list of closures that are
...
@@ -167,7 +165,7 @@ class ChangeNotifier implements Listenable {
...
@@ -167,7 +165,7 @@ class ChangeNotifier implements Listenable {
@override
@override
void
removeListener
(
VoidCallback
listener
)
{
void
removeListener
(
VoidCallback
listener
)
{
assert
(
_debugAssertNotDisposed
());
assert
(
_debugAssertNotDisposed
());
_listeners
.
remove
(
listener
);
_listeners
!
.
remove
(
listener
);
}
}
/// Discards any resources used by the object. After this is called, the
/// Discards any resources used by the object. After this is called, the
...
@@ -202,10 +200,10 @@ class ChangeNotifier implements Listenable {
...
@@ -202,10 +200,10 @@ class ChangeNotifier implements Listenable {
void
notifyListeners
()
{
void
notifyListeners
()
{
assert
(
_debugAssertNotDisposed
());
assert
(
_debugAssertNotDisposed
());
if
(
_listeners
!=
null
)
{
if
(
_listeners
!=
null
)
{
final
List
<
VoidCallback
>
localListeners
=
List
<
VoidCallback
>.
from
(
_listeners
);
final
List
<
VoidCallback
>
localListeners
=
List
<
VoidCallback
>.
from
(
_listeners
!
);
for
(
final
VoidCallback
listener
in
localListeners
)
{
for
(
final
VoidCallback
listener
in
localListeners
)
{
try
{
try
{
if
(
_listeners
.
contains
(
listener
))
if
(
_listeners
!
.
contains
(
listener
))
listener
();
listener
();
}
catch
(
exception
,
stack
)
{
}
catch
(
exception
,
stack
)
{
FlutterError
.
reportError
(
FlutterErrorDetails
(
FlutterError
.
reportError
(
FlutterErrorDetails
(
...
@@ -230,18 +228,18 @@ class ChangeNotifier implements Listenable {
...
@@ -230,18 +228,18 @@ class ChangeNotifier implements Listenable {
class
_MergingListenable
extends
Listenable
{
class
_MergingListenable
extends
Listenable
{
_MergingListenable
(
this
.
_children
);
_MergingListenable
(
this
.
_children
);
final
List
<
Listenable
>
_children
;
final
List
<
Listenable
?
>
_children
;
@override
@override
void
addListener
(
VoidCallback
listener
)
{
void
addListener
(
VoidCallback
listener
)
{
for
(
final
Listenable
child
in
_children
)
{
for
(
final
Listenable
?
child
in
_children
)
{
child
?.
addListener
(
listener
);
child
?.
addListener
(
listener
);
}
}
}
}
@override
@override
void
removeListener
(
VoidCallback
listener
)
{
void
removeListener
(
VoidCallback
listener
)
{
for
(
final
Listenable
child
in
_children
)
{
for
(
final
Listenable
?
child
in
_children
)
{
child
?.
removeListener
(
listener
);
child
?.
removeListener
(
listener
);
}
}
}
}
...
...
packages/flutter/lib/src/foundation/collections.dart
View file @
978a2e7b
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
// TODO(ianh): These should be on the Set and List classes themselves.
// TODO(ianh): These should be on the Set and List classes themselves.
/// Compares two sets for deep equality.
/// Compares two sets for deep equality.
...
@@ -21,7 +19,7 @@
...
@@ -21,7 +19,7 @@
///
///
/// * [listEquals], which does something similar for lists.
/// * [listEquals], which does something similar for lists.
/// * [mapEquals], which does something similar for maps.
/// * [mapEquals], which does something similar for maps.
bool
setEquals
<
T
>(
Set
<
T
>
a
,
Set
<
T
>
b
)
{
bool
setEquals
<
T
>(
Set
<
T
>
?
a
,
Set
<
T
>?
b
)
{
if
(
a
==
null
)
if
(
a
==
null
)
return
b
==
null
;
return
b
==
null
;
if
(
b
==
null
||
a
.
length
!=
b
.
length
)
if
(
b
==
null
||
a
.
length
!=
b
.
length
)
...
@@ -50,7 +48,7 @@ bool setEquals<T>(Set<T> a, Set<T> b) {
...
@@ -50,7 +48,7 @@ bool setEquals<T>(Set<T> a, Set<T> b) {
///
///
/// * [setEquals], which does something similar for sets.
/// * [setEquals], which does something similar for sets.
/// * [mapEquals], which does something similar for maps.
/// * [mapEquals], which does something similar for maps.
bool
listEquals
<
T
>(
List
<
T
>
a
,
List
<
T
>
b
)
{
bool
listEquals
<
T
>(
List
<
T
>
?
a
,
List
<
T
>?
b
)
{
if
(
a
==
null
)
if
(
a
==
null
)
return
b
==
null
;
return
b
==
null
;
if
(
b
==
null
||
a
.
length
!=
b
.
length
)
if
(
b
==
null
||
a
.
length
!=
b
.
length
)
...
@@ -79,7 +77,7 @@ bool listEquals<T>(List<T> a, List<T> b) {
...
@@ -79,7 +77,7 @@ bool listEquals<T>(List<T> a, List<T> b) {
///
///
/// * [setEquals], which does something similar for sets.
/// * [setEquals], which does something similar for sets.
/// * [listEquals], which does something similar for lists.
/// * [listEquals], which does something similar for lists.
bool
mapEquals
<
T
,
U
>(
Map
<
T
,
U
>
a
,
Map
<
T
,
U
>
b
)
{
bool
mapEquals
<
T
,
U
>(
Map
<
T
,
U
>
?
a
,
Map
<
T
,
U
>?
b
)
{
if
(
a
==
null
)
if
(
a
==
null
)
return
b
==
null
;
return
b
==
null
;
if
(
b
==
null
||
a
.
length
!=
b
.
length
)
if
(
b
==
null
||
a
.
length
!=
b
.
length
)
...
@@ -145,8 +143,8 @@ const int _kMergeSortLimit = 32;
...
@@ -145,8 +143,8 @@ const int _kMergeSortLimit = 32;
void
mergeSort
<
T
>(
void
mergeSort
<
T
>(
List
<
T
>
list
,
{
List
<
T
>
list
,
{
int
start
=
0
,
int
start
=
0
,
int
end
,
int
?
end
,
int
Function
(
T
,
T
)
compare
,
int
Function
(
T
,
T
)
?
compare
,
})
{
})
{
end
??=
list
.
length
;
end
??=
list
.
length
;
compare
??=
_defaultCompare
<
T
>();
compare
??=
_defaultCompare
<
T
>();
...
@@ -156,7 +154,7 @@ void mergeSort<T>(
...
@@ -156,7 +154,7 @@ void mergeSort<T>(
return
;
return
;
}
}
if
(
length
<
_kMergeSortLimit
)
{
if
(
length
<
_kMergeSortLimit
)
{
_insertionSort
(
list
,
compare:
compare
,
start:
start
,
end:
end
);
_insertionSort
<
T
>
(
list
,
compare:
compare
,
start:
start
,
end:
end
);
return
;
return
;
}
}
// Special case the first split instead of directly calling _mergeSort,
// Special case the first split instead of directly calling _mergeSort,
...
@@ -168,11 +166,11 @@ void mergeSort<T>(
...
@@ -168,11 +166,11 @@ void mergeSort<T>(
final
int
firstLength
=
middle
-
start
;
final
int
firstLength
=
middle
-
start
;
final
int
secondLength
=
end
-
middle
;
final
int
secondLength
=
end
-
middle
;
// secondLength is always the same as firstLength, or one greater.
// secondLength is always the same as firstLength, or one greater.
final
List
<
T
>
scratchSpace
=
List
<
T
>(
secondLength
);
final
List
<
T
?>
scratchSpace
=
List
<
T
?>.
filled
(
secondLength
,
null
,
growable:
false
);
_mergeSort
(
list
,
compare
,
middle
,
end
,
scratchSpace
,
0
);
_mergeSort
<
T
>
(
list
,
compare
,
middle
,
end
,
scratchSpace
,
0
);
final
int
firstTarget
=
end
-
firstLength
;
final
int
firstTarget
=
end
-
firstLength
;
_mergeSort
(
list
,
compare
,
start
,
middle
,
list
,
firstTarget
);
_mergeSort
<
T
>
(
list
,
compare
,
start
,
middle
,
list
,
firstTarget
);
_merge
(
compare
,
list
,
firstTarget
,
end
,
scratchSpace
,
0
,
secondLength
,
list
,
start
);
_merge
<
T
>
(
compare
,
list
,
firstTarget
,
end
,
scratchSpace
,
0
,
secondLength
,
list
,
start
);
}
}
/// Returns a [Comparator] that asserts that its first argument is comparable.
/// Returns a [Comparator] that asserts that its first argument is comparable.
...
@@ -202,9 +200,9 @@ Comparator<T> _defaultCompare<T>() {
...
@@ -202,9 +200,9 @@ Comparator<T> _defaultCompare<T>() {
/// they started in.
/// they started in.
void
_insertionSort
<
T
>(
void
_insertionSort
<
T
>(
List
<
T
>
list
,
{
List
<
T
>
list
,
{
int
Function
(
T
,
T
)
compare
,
int
Function
(
T
,
T
)
?
compare
,
int
start
=
0
,
int
start
=
0
,
int
end
,
int
?
end
,
})
{
})
{
// If the same method could have both positional and named optional
// If the same method could have both positional and named optional
// parameters, this should be (list, [start, end], {compare}).
// parameters, this should be (list, [start, end], {compare}).
...
@@ -238,7 +236,7 @@ void _movingInsertionSort<T>(
...
@@ -238,7 +236,7 @@ void _movingInsertionSort<T>(
int
Function
(
T
,
T
)
compare
,
int
Function
(
T
,
T
)
compare
,
int
start
,
int
start
,
int
end
,
int
end
,
List
<
T
>
target
,
List
<
T
?
>
target
,
int
targetOffset
,
int
targetOffset
,
)
{
)
{
final
int
length
=
end
-
start
;
final
int
length
=
end
-
start
;
...
@@ -252,7 +250,7 @@ void _movingInsertionSort<T>(
...
@@ -252,7 +250,7 @@ void _movingInsertionSort<T>(
int
max
=
targetOffset
+
i
;
int
max
=
targetOffset
+
i
;
while
(
min
<
max
)
{
while
(
min
<
max
)
{
final
int
mid
=
min
+
((
max
-
min
)
>>
1
);
final
int
mid
=
min
+
((
max
-
min
)
>>
1
);
if
(
compare
(
element
,
target
[
mid
])
<
0
)
{
if
(
compare
(
element
,
target
[
mid
]
as
T
)
<
0
)
{
max
=
mid
;
max
=
mid
;
}
else
{
}
else
{
min
=
mid
+
1
;
min
=
mid
+
1
;
...
@@ -275,12 +273,12 @@ void _mergeSort<T>(
...
@@ -275,12 +273,12 @@ void _mergeSort<T>(
int
Function
(
T
,
T
)
compare
,
int
Function
(
T
,
T
)
compare
,
int
start
,
int
start
,
int
end
,
int
end
,
List
<
T
>
target
,
List
<
T
?
>
target
,
int
targetOffset
,
int
targetOffset
,
)
{
)
{
final
int
length
=
end
-
start
;
final
int
length
=
end
-
start
;
if
(
length
<
_kMergeSortLimit
)
{
if
(
length
<
_kMergeSortLimit
)
{
_movingInsertionSort
(
list
,
compare
,
start
,
end
,
target
,
targetOffset
);
_movingInsertionSort
<
T
>
(
list
,
compare
,
start
,
end
,
target
,
targetOffset
);
return
;
return
;
}
}
final
int
middle
=
start
+
(
length
>>
1
);
final
int
middle
=
start
+
(
length
>>
1
);
...
@@ -289,11 +287,11 @@ void _mergeSort<T>(
...
@@ -289,11 +287,11 @@ void _mergeSort<T>(
// Here secondLength >= firstLength (differs by at most one).
// Here secondLength >= firstLength (differs by at most one).
final
int
targetMiddle
=
targetOffset
+
firstLength
;
final
int
targetMiddle
=
targetOffset
+
firstLength
;
// Sort the second half into the end of the target area.
// Sort the second half into the end of the target area.
_mergeSort
(
list
,
compare
,
middle
,
end
,
target
,
targetMiddle
);
_mergeSort
<
T
>
(
list
,
compare
,
middle
,
end
,
target
,
targetMiddle
);
// Sort the first half into the end of the source area.
// Sort the first half into the end of the source area.
_mergeSort
(
list
,
compare
,
start
,
middle
,
list
,
middle
);
_mergeSort
<
T
>
(
list
,
compare
,
start
,
middle
,
list
,
middle
);
// Merge the two parts into the target area.
// Merge the two parts into the target area.
_merge
(
_merge
<
T
>
(
compare
,
compare
,
list
,
list
,
middle
,
middle
,
...
@@ -318,10 +316,10 @@ void _merge<T>(
...
@@ -318,10 +316,10 @@ void _merge<T>(
List
<
T
>
firstList
,
List
<
T
>
firstList
,
int
firstStart
,
int
firstStart
,
int
firstEnd
,
int
firstEnd
,
List
<
T
>
secondList
,
List
<
T
?
>
secondList
,
int
secondStart
,
int
secondStart
,
int
secondEnd
,
int
secondEnd
,
List
<
T
>
target
,
List
<
T
?
>
target
,
int
targetOffset
,
int
targetOffset
,
)
{
)
{
// No empty lists reaches here.
// No empty lists reaches here.
...
@@ -330,7 +328,7 @@ void _merge<T>(
...
@@ -330,7 +328,7 @@ void _merge<T>(
int
cursor1
=
firstStart
;
int
cursor1
=
firstStart
;
int
cursor2
=
secondStart
;
int
cursor2
=
secondStart
;
T
firstElement
=
firstList
[
cursor1
++];
T
firstElement
=
firstList
[
cursor1
++];
T
secondElement
=
secondList
[
cursor2
++];
T
secondElement
=
secondList
[
cursor2
++]
as
T
;
while
(
true
)
{
while
(
true
)
{
if
(
compare
(
firstElement
,
secondElement
)
<=
0
)
{
if
(
compare
(
firstElement
,
secondElement
)
<=
0
)
{
target
[
targetOffset
++]
=
firstElement
;
target
[
targetOffset
++]
=
firstElement
;
...
@@ -342,7 +340,7 @@ void _merge<T>(
...
@@ -342,7 +340,7 @@ void _merge<T>(
}
else
{
}
else
{
target
[
targetOffset
++]
=
secondElement
;
target
[
targetOffset
++]
=
secondElement
;
if
(
cursor2
!=
secondEnd
)
{
if
(
cursor2
!=
secondEnd
)
{
secondElement
=
secondList
[
cursor2
++];
secondElement
=
secondList
[
cursor2
++]
as
T
;
continue
;
continue
;
}
}
// Second list empties first. Flushing first list here.
// Second list empties first. Flushing first list here.
...
...
packages/flutter/lib/src/foundation/consolidate_response.dart
View file @
978a2e7b
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:async'
;
import
'dart:async'
;
import
'dart:convert'
;
import
'dart:convert'
;
import
'dart:io'
;
import
'dart:io'
;
...
@@ -25,7 +23,7 @@ import 'dart:typed_data';
...
@@ -25,7 +23,7 @@ import 'dart:typed_data';
/// until the request has been fully processed).
/// until the request has been fully processed).
///
///
/// This is used in [consolidateHttpClientResponseBytes].
/// This is used in [consolidateHttpClientResponseBytes].
typedef
BytesReceivedCallback
=
void
Function
(
int
cumulative
,
int
total
);
typedef
BytesReceivedCallback
=
void
Function
(
int
cumulative
,
int
?
total
);
/// Efficiently converts the response body of an [HttpClientResponse] into a
/// Efficiently converts the response body of an [HttpClientResponse] into a
/// [Uint8List].
/// [Uint8List].
...
@@ -48,14 +46,14 @@ typedef BytesReceivedCallback = void Function(int cumulative, int total);
...
@@ -48,14 +46,14 @@ typedef BytesReceivedCallback = void Function(int cumulative, int total);
Future
<
Uint8List
>
consolidateHttpClientResponseBytes
(
Future
<
Uint8List
>
consolidateHttpClientResponseBytes
(
HttpClientResponse
response
,
{
HttpClientResponse
response
,
{
bool
autoUncompress
=
true
,
bool
autoUncompress
=
true
,
BytesReceivedCallback
onBytesReceived
,
BytesReceivedCallback
?
onBytesReceived
,
})
{
})
{
assert
(
autoUncompress
!=
null
);
assert
(
autoUncompress
!=
null
);
final
Completer
<
Uint8List
>
completer
=
Completer
<
Uint8List
>.
sync
();
final
Completer
<
Uint8List
>
completer
=
Completer
<
Uint8List
>.
sync
();
final
_OutputBuffer
output
=
_OutputBuffer
();
final
_OutputBuffer
output
=
_OutputBuffer
();
ByteConversionSink
sink
=
output
;
ByteConversionSink
sink
=
output
;
int
expectedContentLength
=
response
.
contentLength
;
int
?
expectedContentLength
=
response
.
contentLength
;
if
(
expectedContentLength
==
-
1
)
if
(
expectedContentLength
==
-
1
)
expectedContentLength
=
null
;
expectedContentLength
=
null
;
switch
(
response
.
compressionState
)
{
switch
(
response
.
compressionState
)
{
...
@@ -76,7 +74,7 @@ Future<Uint8List> consolidateHttpClientResponseBytes(
...
@@ -76,7 +74,7 @@ Future<Uint8List> consolidateHttpClientResponseBytes(
}
}
int
bytesReceived
=
0
;
int
bytesReceived
=
0
;
StreamSubscription
<
List
<
int
>>
subscription
;
late
final
StreamSubscription
<
List
<
int
>>
subscription
;
subscription
=
response
.
listen
((
List
<
int
>
chunk
)
{
subscription
=
response
.
listen
((
List
<
int
>
chunk
)
{
sink
.
add
(
chunk
);
sink
.
add
(
chunk
);
if
(
onBytesReceived
!=
null
)
{
if
(
onBytesReceived
!=
null
)
{
...
@@ -98,14 +96,14 @@ Future<Uint8List> consolidateHttpClientResponseBytes(
...
@@ -98,14 +96,14 @@ Future<Uint8List> consolidateHttpClientResponseBytes(
}
}
class
_OutputBuffer
extends
ByteConversionSinkBase
{
class
_OutputBuffer
extends
ByteConversionSinkBase
{
List
<
List
<
int
>>
_chunks
=
<
List
<
int
>>[];
List
<
List
<
int
>>
?
_chunks
=
<
List
<
int
>>[];
int
_contentLength
=
0
;
int
_contentLength
=
0
;
Uint8List
_bytes
;
Uint8List
?
_bytes
;
@override
@override
void
add
(
List
<
int
>
chunk
)
{
void
add
(
List
<
int
>
chunk
)
{
assert
(
_bytes
==
null
);
assert
(
_bytes
==
null
);
_chunks
.
add
(
chunk
);
_chunks
!
.
add
(
chunk
);
_contentLength
+=
chunk
.
length
;
_contentLength
+=
chunk
.
length
;
}
}
...
@@ -117,8 +115,8 @@ class _OutputBuffer extends ByteConversionSinkBase {
...
@@ -117,8 +115,8 @@ class _OutputBuffer extends ByteConversionSinkBase {
}
}
_bytes
=
Uint8List
(
_contentLength
);
_bytes
=
Uint8List
(
_contentLength
);
int
offset
=
0
;
int
offset
=
0
;
for
(
final
List
<
int
>
chunk
in
_chunks
)
{
for
(
final
List
<
int
>
chunk
in
_chunks
!
)
{
_bytes
.
setRange
(
offset
,
offset
+
chunk
.
length
,
chunk
);
_bytes
!
.
setRange
(
offset
,
offset
+
chunk
.
length
,
chunk
);
offset
+=
chunk
.
length
;
offset
+=
chunk
.
length
;
}
}
_chunks
=
null
;
_chunks
=
null
;
...
@@ -126,6 +124,6 @@ class _OutputBuffer extends ByteConversionSinkBase {
...
@@ -126,6 +124,6 @@ class _OutputBuffer extends ByteConversionSinkBase {
Uint8List
get
bytes
{
Uint8List
get
bytes
{
assert
(
_bytes
!=
null
);
assert
(
_bytes
!=
null
);
return
_bytes
;
return
_bytes
!
;
}
}
}
}
packages/flutter/lib/src/foundation/constants.dart
View file @
978a2e7b
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
/// A constant that is true if the application was compiled in release mode.
/// A constant that is true if the application was compiled in release mode.
///
///
/// More specifically, this is a constant that is true if the application was
/// More specifically, this is a constant that is true if the application was
...
...
packages/flutter/lib/src/foundation/debug.dart
View file @
978a2e7b
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:async'
;
import
'dart:async'
;
import
'dart:ui'
as
ui
show
Brightness
;
import
'dart:ui'
as
ui
show
Brightness
;
...
@@ -54,7 +52,7 @@ bool debugInstrumentationEnabled = false;
...
@@ -54,7 +52,7 @@ bool debugInstrumentationEnabled = false;
/// * [Timeline], which is used to record synchronous tracing events for
/// * [Timeline], which is used to record synchronous tracing events for
/// visualization in Chrome's tracing format. This method does not
/// visualization in Chrome's tracing format. This method does not
/// implicitly add any timeline events.
/// implicitly add any timeline events.
Future
<
T
>
debugInstrumentAction
<
T
>(
String
description
,
Future
<
T
>
action
())
{
Future
<
T
>
debugInstrumentAction
<
T
>(
String
description
,
Future
<
T
>
action
())
async
{
bool
instrument
=
false
;
bool
instrument
=
false
;
assert
(()
{
assert
(()
{
instrument
=
debugInstrumentationEnabled
;
instrument
=
debugInstrumentationEnabled
;
...
@@ -62,10 +60,12 @@ Future<T> debugInstrumentAction<T>(String description, Future<T> action()) {
...
@@ -62,10 +60,12 @@ Future<T> debugInstrumentAction<T>(String description, Future<T> action()) {
}());
}());
if
(
instrument
)
{
if
(
instrument
)
{
final
Stopwatch
stopwatch
=
Stopwatch
()..
start
();
final
Stopwatch
stopwatch
=
Stopwatch
()..
start
();
return
action
().
whenComplete
(()
{
try
{
return
await
action
();
}
finally
{
stopwatch
.
stop
();
stopwatch
.
stop
();
debugPrint
(
'Action "
$description
" took
${stopwatch.elapsed}
'
);
debugPrint
(
'Action "
$description
" took
${stopwatch.elapsed}
'
);
}
);
}
}
else
{
}
else
{
return
action
();
return
action
();
}
}
...
@@ -87,17 +87,17 @@ const Map<String, String> timelineArgumentsIndicatingLandmarkEvent = <String, St
...
@@ -87,17 +87,17 @@ const Map<String, String> timelineArgumentsIndicatingLandmarkEvent = <String, St
/// Configure [debugFormatDouble] using [num.toStringAsPrecision].
/// Configure [debugFormatDouble] using [num.toStringAsPrecision].
///
///
/// Defaults to null, which uses the default logic of [debugFormatDouble].
/// Defaults to null, which uses the default logic of [debugFormatDouble].
int
debugDoublePrecision
;
int
?
debugDoublePrecision
;
/// Formats a double to have standard formatting.
/// Formats a double to have standard formatting.
///
///
/// This behavior can be overridden by [debugDoublePrecision].
/// This behavior can be overridden by [debugDoublePrecision].
String
debugFormatDouble
(
double
value
)
{
String
debugFormatDouble
(
double
?
value
)
{
if
(
value
==
null
)
{
if
(
value
==
null
)
{
return
'null'
;
return
'null'
;
}
}
if
(
debugDoublePrecision
!=
null
)
{
if
(
debugDoublePrecision
!=
null
)
{
return
value
.
toStringAsPrecision
(
debugDoublePrecision
);
return
value
.
toStringAsPrecision
(
debugDoublePrecision
!
);
}
}
return
value
.
toStringAsFixed
(
1
);
return
value
.
toStringAsFixed
(
1
);
}
}
...
@@ -109,4 +109,4 @@ String debugFormatDouble(double value) {
...
@@ -109,4 +109,4 @@ String debugFormatDouble(double value) {
///
///
/// * [WidgetsApp], which uses the [debugBrightnessOverride] setting in debug mode
/// * [WidgetsApp], which uses the [debugBrightnessOverride] setting in debug mode
/// to construct a [MediaQueryData].
/// to construct a [MediaQueryData].
ui
.
Brightness
debugBrightnessOverride
;
ui
.
Brightness
?
debugBrightnessOverride
;
packages/flutter/lib/src/foundation/diagnostics.dart
View file @
978a2e7b
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:math'
as
math
;
import
'dart:math'
as
math
;
import
'package:meta/meta.dart'
;
import
'package:meta/meta.dart'
;
...
@@ -203,13 +201,13 @@ class TextTreeConfiguration {
...
@@ -203,13 +201,13 @@ class TextTreeConfiguration {
///
///
/// All of the arguments must not be null.
/// All of the arguments must not be null.
TextTreeConfiguration
({
TextTreeConfiguration
({
@
required
this
.
prefixLineOne
,
required
this
.
prefixLineOne
,
@
required
this
.
prefixOtherLines
,
required
this
.
prefixOtherLines
,
@
required
this
.
prefixLastChildLineOne
,
required
this
.
prefixLastChildLineOne
,
@
required
this
.
prefixOtherLinesRootNode
,
required
this
.
prefixOtherLinesRootNode
,
@
required
this
.
linkCharacter
,
required
this
.
linkCharacter
,
@
required
this
.
propertyPrefixIfChildren
,
required
this
.
propertyPrefixIfChildren
,
@
required
this
.
propertyPrefixNoChildren
,
required
this
.
propertyPrefixNoChildren
,
this
.
lineBreak
=
'
\n
'
,
this
.
lineBreak
=
'
\n
'
,
this
.
lineBreakProperties
=
true
,
this
.
lineBreakProperties
=
true
,
this
.
afterName
=
':'
,
this
.
afterName
=
':'
,
...
@@ -786,8 +784,8 @@ enum _WordWrapParseMode { inSpace, inWord, atBreak }
...
@@ -786,8 +784,8 @@ enum _WordWrapParseMode { inSpace, inWord, atBreak }
/// [prefixOtherLines].
/// [prefixOtherLines].
class
_PrefixedStringBuilder
{
class
_PrefixedStringBuilder
{
_PrefixedStringBuilder
({
_PrefixedStringBuilder
({
@
required
this
.
prefixLineOne
,
required
this
.
prefixLineOne
,
@required
String
prefixOtherLines
,
required
String
?
prefixOtherLines
,
this
.
wrapWidth
})
:
this
.
wrapWidth
})
:
_prefixOtherLines
=
prefixOtherLines
;
_prefixOtherLines
=
prefixOtherLines
;
...
@@ -798,24 +796,24 @@ class _PrefixedStringBuilder {
...
@@ -798,24 +796,24 @@ class _PrefixedStringBuilder {
///
///
/// The prefix can be modified while the string is being built in which case
/// The prefix can be modified while the string is being built in which case
/// subsequent lines will be added with the modified prefix.
/// subsequent lines will be added with the modified prefix.
String
get
prefixOtherLines
=>
_nextPrefixOtherLines
??
_prefixOtherLines
;
String
?
get
prefixOtherLines
=>
_nextPrefixOtherLines
??
_prefixOtherLines
;
String
_prefixOtherLines
;
String
?
_prefixOtherLines
;
set
prefixOtherLines
(
String
prefix
)
{
set
prefixOtherLines
(
String
?
prefix
)
{
_prefixOtherLines
=
prefix
;
_prefixOtherLines
=
prefix
;
_nextPrefixOtherLines
=
null
;
_nextPrefixOtherLines
=
null
;
}
}
String
_nextPrefixOtherLines
;
String
?
_nextPrefixOtherLines
;
void
incrementPrefixOtherLines
(
String
suffix
,
{
@
required
bool
updateCurrentLine
})
{
void
incrementPrefixOtherLines
(
String
suffix
,
{
required
bool
updateCurrentLine
})
{
if
(
_currentLine
.
isEmpty
||
updateCurrentLine
)
{
if
(
_currentLine
.
isEmpty
||
updateCurrentLine
)
{
_prefixOtherLines
=
prefixOtherLines
+
suffix
;
_prefixOtherLines
=
prefixOtherLines
!
+
suffix
;
_nextPrefixOtherLines
=
null
;
_nextPrefixOtherLines
=
null
;
}
else
{
}
else
{
_nextPrefixOtherLines
=
prefixOtherLines
+
suffix
;
_nextPrefixOtherLines
=
prefixOtherLines
!
+
suffix
;
}
}
}
}
final
int
wrapWidth
;
final
int
?
wrapWidth
;
/// Buffer containing lines that have already been completely laid out.
/// Buffer containing lines that have already been completely laid out.
final
StringBuffer
_buffer
=
StringBuffer
();
final
StringBuffer
_buffer
=
StringBuffer
();
...
@@ -827,7 +825,7 @@ class _PrefixedStringBuilder {
...
@@ -827,7 +825,7 @@ class _PrefixedStringBuilder {
/// Whether the string being built already has more than 1 line.
/// Whether the string being built already has more than 1 line.
bool
get
requiresMultipleLines
=>
_numLines
>
1
||
(
_numLines
==
1
&&
_currentLine
.
isNotEmpty
)
||
bool
get
requiresMultipleLines
=>
_numLines
>
1
||
(
_numLines
==
1
&&
_currentLine
.
isNotEmpty
)
||
(
_currentLine
.
length
+
_getCurrentPrefix
(
true
)
.
length
>
wrapWidth
);
(
_currentLine
.
length
+
_getCurrentPrefix
(
true
)
!.
length
>
wrapWidth
!
);
bool
get
isCurrentLineEmpty
=>
_currentLine
.
isEmpty
;
bool
get
isCurrentLineEmpty
=>
_currentLine
.
isEmpty
;
...
@@ -850,9 +848,9 @@ class _PrefixedStringBuilder {
...
@@ -850,9 +848,9 @@ class _PrefixedStringBuilder {
final
Iterable
<
String
>
lines
=
_wordWrapLine
(
final
Iterable
<
String
>
lines
=
_wordWrapLine
(
text
,
text
,
_wrappableRanges
,
_wrappableRanges
,
wrapWidth
,
wrapWidth
!
,
startOffset:
firstLine
?
prefixLineOne
.
length
:
_prefixOtherLines
.
length
,
startOffset:
firstLine
?
prefixLineOne
.
length
:
_prefixOtherLines
!
.
length
,
otherLineOffset:
firstLine
?
_prefixOtherLines
.
length
:
_prefixOtherLines
.
length
,
otherLineOffset:
firstLine
?
_prefixOtherLines
!.
length
:
_prefixOtherLines
!
.
length
,
);
);
int
i
=
0
;
int
i
=
0
;
final
int
length
=
lines
.
length
;
final
int
length
=
lines
.
length
;
...
@@ -887,8 +885,8 @@ class _PrefixedStringBuilder {
...
@@ -887,8 +885,8 @@ class _PrefixedStringBuilder {
bool
addPrefix
=
false
;
bool
addPrefix
=
false
;
int
index
=
0
;
int
index
=
0
;
_WordWrapParseMode
mode
=
_WordWrapParseMode
.
inSpace
;
_WordWrapParseMode
mode
=
_WordWrapParseMode
.
inSpace
;
int
lastWordStart
;
late
int
lastWordStart
;
int
lastWordEnd
;
int
?
lastWordEnd
;
int
start
=
0
;
int
start
=
0
;
int
currentChunk
=
0
;
int
currentChunk
=
0
;
...
@@ -1000,8 +998,8 @@ class _PrefixedStringBuilder {
...
@@ -1000,8 +998,8 @@ class _PrefixedStringBuilder {
void
_writeLine
(
void
_writeLine
(
String
line
,
{
String
line
,
{
@
required
bool
includeLineBreak
,
required
bool
includeLineBreak
,
@
required
bool
firstLine
,
required
bool
firstLine
,
})
{
})
{
line
=
'
${_getCurrentPrefix(firstLine)}$line
'
;
line
=
'
${_getCurrentPrefix(firstLine)}$line
'
;
_buffer
.
write
(
line
.
trimRight
());
_buffer
.
write
(
line
.
trimRight
());
...
@@ -1010,7 +1008,7 @@ class _PrefixedStringBuilder {
...
@@ -1010,7 +1008,7 @@ class _PrefixedStringBuilder {
_numLines
++;
_numLines
++;
}
}
String
_getCurrentPrefix
(
bool
firstLine
)
{
String
?
_getCurrentPrefix
(
bool
firstLine
)
{
return
_buffer
.
isEmpty
?
prefixLineOne
:
(
firstLine
?
_prefixOtherLines
:
_prefixOtherLines
);
return
_buffer
.
isEmpty
?
prefixLineOne
:
(
firstLine
?
_prefixOtherLines
:
_prefixOtherLines
);
}
}
...
@@ -1035,7 +1033,7 @@ class _PrefixedStringBuilder {
...
@@ -1035,7 +1033,7 @@ class _PrefixedStringBuilder {
/// Finishes the current line with a stretched version of text.
/// Finishes the current line with a stretched version of text.
void
writeStretched
(
String
text
,
int
targetLineLength
)
{
void
writeStretched
(
String
text
,
int
targetLineLength
)
{
write
(
text
);
write
(
text
);
final
int
currentLineLength
=
_currentLine
.
length
+
_getCurrentPrefix
(
_buffer
.
isEmpty
).
length
;
final
int
currentLineLength
=
_currentLine
.
length
+
_getCurrentPrefix
(
_buffer
.
isEmpty
)
!
.
length
;
assert
(
_currentLine
.
length
>
0
);
assert
(
_currentLine
.
length
>
0
);
final
int
targetLength
=
targetLineLength
-
currentLineLength
;
final
int
targetLength
=
targetLineLength
-
currentLineLength
;
if
(
targetLength
>
0
)
{
if
(
targetLength
>
0
)
{
...
@@ -1063,7 +1061,7 @@ class _NoDefaultValue {
...
@@ -1063,7 +1061,7 @@ class _NoDefaultValue {
/// Marker object indicating that a [DiagnosticsNode] has no default value.
/// Marker object indicating that a [DiagnosticsNode] has no default value.
const
_NoDefaultValue
kNoDefaultValue
=
_NoDefaultValue
();
const
_NoDefaultValue
kNoDefaultValue
=
_NoDefaultValue
();
bool
_isSingleLine
(
DiagnosticsTreeStyle
style
)
{
bool
_isSingleLine
(
DiagnosticsTreeStyle
?
style
)
{
return
style
==
DiagnosticsTreeStyle
.
singleLine
;
return
style
==
DiagnosticsTreeStyle
.
singleLine
;
}
}
...
@@ -1107,11 +1105,11 @@ class TextTreeRenderer {
...
@@ -1107,11 +1105,11 @@ class TextTreeRenderer {
/// parent to the child should be consistent with the parent's style as the
/// parent to the child should be consistent with the parent's style as the
/// single line style does not provide any meaningful style for how children
/// single line style does not provide any meaningful style for how children
/// should be connected to their parents.
/// should be connected to their parents.
TextTreeConfiguration
_childTextConfiguration
(
TextTreeConfiguration
?
_childTextConfiguration
(
DiagnosticsNode
child
,
DiagnosticsNode
child
,
TextTreeConfiguration
textStyle
,
TextTreeConfiguration
textStyle
,
)
{
)
{
final
DiagnosticsTreeStyle
childStyle
=
child
?
.
style
;
final
DiagnosticsTreeStyle
?
childStyle
=
child
.
style
;
return
(
_isSingleLine
(
childStyle
)
||
childStyle
==
DiagnosticsTreeStyle
.
errorProperty
)
?
textStyle
:
child
.
textTreeConfiguration
;
return
(
_isSingleLine
(
childStyle
)
||
childStyle
==
DiagnosticsTreeStyle
.
errorProperty
)
?
textStyle
:
child
.
textTreeConfiguration
;
}
}
...
@@ -1119,8 +1117,8 @@ class TextTreeRenderer {
...
@@ -1119,8 +1117,8 @@ class TextTreeRenderer {
String
render
(
String
render
(
DiagnosticsNode
node
,
{
DiagnosticsNode
node
,
{
String
prefixLineOne
=
''
,
String
prefixLineOne
=
''
,
String
prefixOtherLines
,
String
?
prefixOtherLines
,
TextTreeConfiguration
parentConfiguration
,
TextTreeConfiguration
?
parentConfiguration
,
})
{
})
{
if
(
kReleaseMode
)
{
if
(
kReleaseMode
)
{
return
''
;
return
''
;
...
@@ -1136,17 +1134,17 @@ class TextTreeRenderer {
...
@@ -1136,17 +1134,17 @@ class TextTreeRenderer {
String
_debugRender
(
String
_debugRender
(
DiagnosticsNode
node
,
{
DiagnosticsNode
node
,
{
String
prefixLineOne
=
''
,
String
prefixLineOne
=
''
,
String
prefixOtherLines
,
String
?
prefixOtherLines
,
TextTreeConfiguration
parentConfiguration
,
TextTreeConfiguration
?
parentConfiguration
,
})
{
})
{
final
bool
isSingleLine
=
_isSingleLine
(
node
.
style
)
&&
parentConfiguration
?.
lineBreakProperties
!=
true
;
final
bool
isSingleLine
=
_isSingleLine
(
node
.
style
)
&&
parentConfiguration
?.
lineBreakProperties
!=
true
;
prefixOtherLines
??=
prefixLineOne
;
prefixOtherLines
??=
prefixLineOne
;
if
(
node
.
linePrefix
!=
null
)
{
if
(
node
.
linePrefix
!=
null
)
{
prefixLineOne
+=
node
.
linePrefix
;
prefixLineOne
+=
node
.
linePrefix
!
;
prefixOtherLines
+=
node
.
linePrefix
;
prefixOtherLines
+=
node
.
linePrefix
!
;
}
}
final
TextTreeConfiguration
config
=
node
.
textTreeConfiguration
;
final
TextTreeConfiguration
config
=
node
.
textTreeConfiguration
!
;
if
(
prefixOtherLines
.
isEmpty
)
if
(
prefixOtherLines
.
isEmpty
)
prefixOtherLines
+=
config
.
prefixOtherLinesRootNode
;
prefixOtherLines
+=
config
.
prefixOtherLinesRootNode
;
...
@@ -1192,14 +1190,14 @@ class TextTreeRenderer {
...
@@ -1192,14 +1190,14 @@ class TextTreeRenderer {
List
<
DiagnosticsNode
>
children
=
node
.
getChildren
();
List
<
DiagnosticsNode
>
children
=
node
.
getChildren
();
String
description
=
node
.
toDescription
(
parentConfiguration:
parentConfiguration
);
String
?
description
=
node
.
toDescription
(
parentConfiguration:
parentConfiguration
);
if
(
config
.
beforeName
.
isNotEmpty
)
{
if
(
config
.
beforeName
.
isNotEmpty
)
{
builder
.
write
(
config
.
beforeName
);
builder
.
write
(
config
.
beforeName
);
}
}
final
bool
wrapName
=
!
isSingleLine
&&
node
.
allowNameWrap
;
final
bool
wrapName
=
!
isSingleLine
&&
node
.
allowNameWrap
;
final
bool
wrapDescription
=
!
isSingleLine
&&
node
.
allowWrap
;
final
bool
wrapDescription
=
!
isSingleLine
&&
node
.
allowWrap
;
final
bool
uppercaseTitle
=
node
.
style
==
DiagnosticsTreeStyle
.
error
;
final
bool
uppercaseTitle
=
node
.
style
==
DiagnosticsTreeStyle
.
error
;
String
name
=
node
.
name
;
String
?
name
=
node
.
name
;
if
(
uppercaseTitle
)
{
if
(
uppercaseTitle
)
{
name
=
name
?.
toUpperCase
();
name
=
name
?.
toUpperCase
();
}
}
...
@@ -1244,7 +1242,7 @@ class TextTreeRenderer {
...
@@ -1244,7 +1242,7 @@ class TextTreeRenderer {
}
}
}
}
if
(
config
.
suffixLineOne
.
isNotEmpty
)
{
if
(
config
.
suffixLineOne
.
isNotEmpty
)
{
builder
.
writeStretched
(
config
.
suffixLineOne
,
builder
.
wrapWidth
);
builder
.
writeStretched
(
config
.
suffixLineOne
,
builder
.
wrapWidth
!
);
}
}
final
Iterable
<
DiagnosticsNode
>
propertiesIterable
=
node
.
getProperties
().
where
(
final
Iterable
<
DiagnosticsNode
>
propertiesIterable
=
node
.
getProperties
().
where
(
...
@@ -1287,7 +1285,7 @@ class TextTreeRenderer {
...
@@ -1287,7 +1285,7 @@ class TextTreeRenderer {
properties
.
isEmpty
&&
properties
.
isEmpty
&&
children
.
isEmpty
&&
children
.
isEmpty
&&
prefixLineOne
.
isNotEmpty
)
{
prefixLineOne
.
isNotEmpty
)
{
builder
.
write
(
node
.
emptyBodyDescription
);
builder
.
write
(
node
.
emptyBodyDescription
!
);
if
(
config
.
lineBreakProperties
)
if
(
config
.
lineBreakProperties
)
builder
.
write
(
config
.
lineBreak
);
builder
.
write
(
config
.
lineBreak
);
}
}
...
@@ -1297,7 +1295,7 @@ class TextTreeRenderer {
...
@@ -1297,7 +1295,7 @@ class TextTreeRenderer {
if
(
i
>
0
)
if
(
i
>
0
)
builder
.
write
(
config
.
propertySeparator
);
builder
.
write
(
config
.
propertySeparator
);
final
TextTreeConfiguration
propertyStyle
=
property
.
textTreeConfiguration
;
final
TextTreeConfiguration
propertyStyle
=
property
.
textTreeConfiguration
!
;
if
(
_isSingleLine
(
property
.
style
))
{
if
(
_isSingleLine
(
property
.
style
))
{
// We have to treat single line properties slightly differently to deal
// We have to treat single line properties slightly differently to deal
// with cases where a single line properties output may not have single
// with cases where a single line properties output may not have single
...
@@ -1337,7 +1335,7 @@ class TextTreeRenderer {
...
@@ -1337,7 +1335,7 @@ class TextTreeRenderer {
if
(
children
.
isEmpty
&&
if
(
children
.
isEmpty
&&
config
.
addBlankLineIfNoChildren
&&
config
.
addBlankLineIfNoChildren
&&
builder
.
requiresMultipleLines
&&
builder
.
requiresMultipleLines
&&
builder
.
prefixOtherLines
.
trimRight
().
isNotEmpty
builder
.
prefixOtherLines
!
.
trimRight
().
isNotEmpty
)
{
)
{
builder
.
write
(
config
.
lineBreak
);
builder
.
write
(
config
.
lineBreak
);
}
}
...
@@ -1345,7 +1343,7 @@ class TextTreeRenderer {
...
@@ -1345,7 +1343,7 @@ class TextTreeRenderer {
if
(
children
.
isNotEmpty
&&
config
.
showChildren
)
{
if
(
children
.
isNotEmpty
&&
config
.
showChildren
)
{
if
(
config
.
isBlankLineBetweenPropertiesAndChildren
&&
if
(
config
.
isBlankLineBetweenPropertiesAndChildren
&&
properties
.
isNotEmpty
&&
properties
.
isNotEmpty
&&
children
.
first
.
textTreeConfiguration
.
isBlankLineBetweenPropertiesAndChildren
)
{
children
.
first
.
textTreeConfiguration
!
.
isBlankLineBetweenPropertiesAndChildren
)
{
builder
.
write
(
config
.
lineBreak
);
builder
.
write
(
config
.
lineBreak
);
}
}
...
@@ -1354,7 +1352,7 @@ class TextTreeRenderer {
...
@@ -1354,7 +1352,7 @@ class TextTreeRenderer {
for
(
int
i
=
0
;
i
<
children
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
children
.
length
;
i
++)
{
final
DiagnosticsNode
child
=
children
[
i
];
final
DiagnosticsNode
child
=
children
[
i
];
assert
(
child
!=
null
);
assert
(
child
!=
null
);
final
TextTreeConfiguration
childConfig
=
_childTextConfiguration
(
child
,
config
);
final
TextTreeConfiguration
childConfig
=
_childTextConfiguration
(
child
,
config
)
!
;
if
(
i
==
children
.
length
-
1
)
{
if
(
i
==
children
.
length
-
1
)
{
final
String
lastChildPrefixLineOne
=
'
$prefixChildrenRaw${childConfig.prefixLastChildLineOne}
'
;
final
String
lastChildPrefixLineOne
=
'
$prefixChildrenRaw${childConfig.prefixLastChildLineOne}
'
;
final
String
childPrefixOtherLines
=
'
$prefixChildrenRaw${childConfig.childLinkSpace}${childConfig.prefixOtherLines}
'
;
final
String
childPrefixOtherLines
=
'
$prefixChildrenRaw${childConfig.childLinkSpace}${childConfig.prefixOtherLines}
'
;
...
@@ -1370,13 +1368,13 @@ class TextTreeRenderer {
...
@@ -1370,13 +1368,13 @@ class TextTreeRenderer {
if
(
childConfig
.
mandatoryFooter
.
isNotEmpty
)
{
if
(
childConfig
.
mandatoryFooter
.
isNotEmpty
)
{
builder
.
writeStretched
(
builder
.
writeStretched
(
childConfig
.
mandatoryFooter
,
childConfig
.
mandatoryFooter
,
math
.
max
(
builder
.
wrapWidth
,
_wrapWidthProperties
+
childPrefixOtherLines
.
length
),
math
.
max
(
builder
.
wrapWidth
!
,
_wrapWidthProperties
+
childPrefixOtherLines
.
length
),
);
);
}
}
builder
.
write
(
config
.
lineBreak
);
builder
.
write
(
config
.
lineBreak
);
}
}
}
else
{
}
else
{
final
TextTreeConfiguration
nextChildStyle
=
_childTextConfiguration
(
children
[
i
+
1
],
config
);
final
TextTreeConfiguration
nextChildStyle
=
_childTextConfiguration
(
children
[
i
+
1
],
config
)
!
;
final
String
childPrefixLineOne
=
'
$prefixChildrenRaw${childConfig.prefixLineOne}
'
;
final
String
childPrefixLineOne
=
'
$prefixChildrenRaw${childConfig.prefixLineOne}
'
;
final
String
childPrefixOtherLines
=
'
$prefixChildrenRaw${nextChildStyle.linkCharacter}${childConfig.prefixOtherLines}
'
;
final
String
childPrefixOtherLines
=
'
$prefixChildrenRaw${nextChildStyle.linkCharacter}${childConfig.prefixOtherLines}
'
;
builder
.
writeRawLines
(
render
(
builder
.
writeRawLines
(
render
(
...
@@ -1391,7 +1389,7 @@ class TextTreeRenderer {
...
@@ -1391,7 +1389,7 @@ class TextTreeRenderer {
if
(
childConfig
.
mandatoryFooter
.
isNotEmpty
)
{
if
(
childConfig
.
mandatoryFooter
.
isNotEmpty
)
{
builder
.
writeStretched
(
builder
.
writeStretched
(
childConfig
.
mandatoryFooter
,
childConfig
.
mandatoryFooter
,
math
.
max
(
builder
.
wrapWidth
,
_wrapWidthProperties
+
childPrefixOtherLines
.
length
),
math
.
max
(
builder
.
wrapWidth
!
,
_wrapWidthProperties
+
childPrefixOtherLines
.
length
),
);
);
}
}
builder
.
write
(
config
.
lineBreak
);
builder
.
write
(
config
.
lineBreak
);
...
@@ -1400,7 +1398,7 @@ class TextTreeRenderer {
...
@@ -1400,7 +1398,7 @@ class TextTreeRenderer {
}
}
}
}
if
(
parentConfiguration
==
null
&&
config
.
mandatoryFooter
.
isNotEmpty
)
{
if
(
parentConfiguration
==
null
&&
config
.
mandatoryFooter
.
isNotEmpty
)
{
builder
.
writeStretched
(
config
.
mandatoryFooter
,
builder
.
wrapWidth
);
builder
.
writeStretched
(
config
.
mandatoryFooter
,
builder
.
wrapWidth
!
);
builder
.
write
(
config
.
lineBreak
);
builder
.
write
(
config
.
lineBreak
);
}
}
return
builder
.
build
();
return
builder
.
build
();
...
@@ -1423,7 +1421,7 @@ abstract class DiagnosticsNode {
...
@@ -1423,7 +1421,7 @@ abstract class DiagnosticsNode {
/// The [style], [showName], and [showSeparator] arguments must not
/// The [style], [showName], and [showSeparator] arguments must not
/// be null.
/// be null.
DiagnosticsNode
({
DiagnosticsNode
({
@
required
this
.
name
,
required
this
.
name
,
this
.
style
,
this
.
style
,
this
.
showName
=
true
,
this
.
showName
=
true
,
this
.
showSeparator
=
true
,
this
.
showSeparator
=
true
,
...
@@ -1472,7 +1470,7 @@ abstract class DiagnosticsNode {
...
@@ -1472,7 +1470,7 @@ abstract class DiagnosticsNode {
/// (see [showSeparator]).
/// (see [showSeparator]).
///
///
/// The name will be omitted if the [showName] property is false.
/// The name will be omitted if the [showName] property is false.
final
String
name
;
final
String
?
name
;
/// Returns a description with a short summary of the node itself not
/// Returns a description with a short summary of the node itself not
/// including children or properties.
/// including children or properties.
...
@@ -1480,7 +1478,7 @@ abstract class DiagnosticsNode {
...
@@ -1480,7 +1478,7 @@ abstract class DiagnosticsNode {
/// `parentConfiguration` specifies how the parent is rendered as text art.
/// `parentConfiguration` specifies how the parent is rendered as text art.
/// For example, if the parent does not line break between properties, the
/// For example, if the parent does not line break between properties, the
/// description of a property should also be a single line if possible.
/// description of a property should also be a single line if possible.
String
toDescription
({
TextTreeConfiguration
parentConfiguration
});
String
?
toDescription
({
TextTreeConfiguration
?
parentConfiguration
});
/// Whether to show a separator between [name] and description.
/// Whether to show a separator between [name] and description.
///
///
...
@@ -1514,16 +1512,16 @@ abstract class DiagnosticsNode {
...
@@ -1514,16 +1512,16 @@ abstract class DiagnosticsNode {
final
bool
showName
;
final
bool
showName
;
/// Prefix to include at the start of each line
/// Prefix to include at the start of each line
final
String
linePrefix
;
final
String
?
linePrefix
;
/// Description to show if the node has no displayed properties or children.
/// Description to show if the node has no displayed properties or children.
String
get
emptyBodyDescription
=>
null
;
String
?
get
emptyBodyDescription
=>
null
;
/// The actual object this is diagnostics data for.
/// The actual object this is diagnostics data for.
Object
get
value
;
Object
?
get
value
;
/// Hint for how the node should be displayed.
/// Hint for how the node should be displayed.
final
DiagnosticsTreeStyle
style
;
final
DiagnosticsTreeStyle
?
style
;
/// Whether to wrap text on onto multiple lines or not.
/// Whether to wrap text on onto multiple lines or not.
bool
get
allowWrap
=>
false
;
bool
get
allowWrap
=>
false
;
...
@@ -1561,11 +1559,11 @@ abstract class DiagnosticsNode {
...
@@ -1561,11 +1559,11 @@ abstract class DiagnosticsNode {
/// by this method and interactive tree views in the Flutter IntelliJ
/// by this method and interactive tree views in the Flutter IntelliJ
/// plugin.
/// plugin.
@mustCallSuper
@mustCallSuper
Map
<
String
,
Object
>
toJsonMap
(
DiagnosticsSerializationDelegate
delegate
)
{
Map
<
String
,
Object
?
>
toJsonMap
(
DiagnosticsSerializationDelegate
delegate
)
{
Map
<
String
,
Object
>
result
=
<
String
,
Object
>{};
Map
<
String
,
Object
?>
result
=
<
String
,
Object
?
>{};
assert
(()
{
assert
(()
{
final
bool
hasChildren
=
getChildren
().
isNotEmpty
;
final
bool
hasChildren
=
getChildren
().
isNotEmpty
;
result
=
<
String
,
Object
>{
result
=
<
String
,
Object
?
>{
'description'
:
toDescription
(),
'description'
:
toDescription
(),
'type'
:
runtimeType
.
toString
(),
'type'
:
runtimeType
.
toString
(),
if
(
name
!=
null
)
if
(
name
!=
null
)
...
@@ -1579,7 +1577,7 @@ abstract class DiagnosticsNode {
...
@@ -1579,7 +1577,7 @@ abstract class DiagnosticsNode {
if
(
emptyBodyDescription
!=
null
)
if
(
emptyBodyDescription
!=
null
)
'emptyBodyDescription'
:
emptyBodyDescription
,
'emptyBodyDescription'
:
emptyBodyDescription
,
if
(
style
!=
DiagnosticsTreeStyle
.
sparse
)
if
(
style
!=
DiagnosticsTreeStyle
.
sparse
)
'style'
:
describeEnum
(
style
),
'style'
:
describeEnum
(
style
!
),
if
(
allowTruncate
)
if
(
allowTruncate
)
'allowTruncate'
:
allowTruncate
,
'allowTruncate'
:
allowTruncate
,
if
(
hasChildren
)
if
(
hasChildren
)
...
@@ -1614,21 +1612,21 @@ abstract class DiagnosticsNode {
...
@@ -1614,21 +1612,21 @@ abstract class DiagnosticsNode {
///
///
/// The provided `nodes` may be properties or children of the `parent`
/// The provided `nodes` may be properties or children of the `parent`
/// [DiagnosticsNode].
/// [DiagnosticsNode].
static
List
<
Map
<
String
,
Object
>>
toJsonList
(
static
List
<
Map
<
String
,
Object
?
>>
toJsonList
(
List
<
DiagnosticsNode
>
nodes
,
List
<
DiagnosticsNode
>
?
nodes
,
DiagnosticsNode
parent
,
DiagnosticsNode
?
parent
,
DiagnosticsSerializationDelegate
delegate
,
DiagnosticsSerializationDelegate
delegate
,
)
{
)
{
bool
truncated
=
false
;
bool
truncated
=
false
;
if
(
nodes
==
null
)
if
(
nodes
==
null
)
return
const
<
Map
<
String
,
Object
>>[];
return
const
<
Map
<
String
,
Object
?
>>[];
final
int
originalNodeCount
=
nodes
.
length
;
final
int
originalNodeCount
=
nodes
.
length
;
nodes
=
delegate
.
truncateNodesList
(
nodes
,
parent
);
nodes
=
delegate
.
truncateNodesList
(
nodes
,
parent
);
if
(
nodes
.
length
!=
originalNodeCount
)
{
if
(
nodes
.
length
!=
originalNodeCount
)
{
nodes
.
add
(
DiagnosticsNode
.
message
(
'...'
));
nodes
.
add
(
DiagnosticsNode
.
message
(
'...'
));
truncated
=
true
;
truncated
=
true
;
}
}
final
List
<
Map
<
String
,
Object
>>
json
=
nodes
.
map
<
Map
<
String
,
Object
>>((
DiagnosticsNode
node
)
{
final
List
<
Map
<
String
,
Object
?>>
json
=
nodes
.
map
<
Map
<
String
,
Object
?
>>((
DiagnosticsNode
node
)
{
return
node
.
toJsonMap
(
delegate
.
delegateForNode
(
node
));
return
node
.
toJsonMap
(
delegate
.
delegateForNode
(
node
));
}).
toList
();
}).
toList
();
if
(
truncated
)
if
(
truncated
)
...
@@ -1650,7 +1648,7 @@ abstract class DiagnosticsNode {
...
@@ -1650,7 +1648,7 @@ abstract class DiagnosticsNode {
/// not print at all.
/// not print at all.
@override
@override
String
toString
({
String
toString
({
TextTreeConfiguration
parentConfiguration
,
TextTreeConfiguration
?
parentConfiguration
,
DiagnosticLevel
minLevel
=
DiagnosticLevel
.
info
,
DiagnosticLevel
minLevel
=
DiagnosticLevel
.
info
,
})
{
})
{
String
result
=
super
.
toString
();
String
result
=
super
.
toString
();
...
@@ -1661,11 +1659,11 @@ abstract class DiagnosticsNode {
...
@@ -1661,11 +1659,11 @@ abstract class DiagnosticsNode {
result
=
toStringDeep
(
result
=
toStringDeep
(
parentConfiguration:
parentConfiguration
,
minLevel:
minLevel
);
parentConfiguration:
parentConfiguration
,
minLevel:
minLevel
);
}
else
{
}
else
{
final
String
description
=
toDescription
(
String
?
description
=
toDescription
(
parentConfiguration:
parentConfiguration
);
parentConfiguration:
parentConfiguration
);
assert
(
description
!=
null
);
assert
(
description
!=
null
);
description
=
description
!;
if
(
name
==
null
||
name
.
isEmpty
||
!
showName
)
{
if
(
name
==
null
||
name
!
.
isEmpty
||
!
showName
)
{
result
=
description
;
result
=
description
;
}
else
{
}
else
{
result
=
description
.
contains
(
'
\n
'
)
?
'
$name$_separator
\n
$description
'
result
=
description
.
contains
(
'
\n
'
)
?
'
$name$_separator
\n
$description
'
...
@@ -1680,9 +1678,9 @@ abstract class DiagnosticsNode {
...
@@ -1680,9 +1678,9 @@ abstract class DiagnosticsNode {
/// Returns a configuration specifying how this object should be rendered
/// Returns a configuration specifying how this object should be rendered
/// as text art.
/// as text art.
@protected
@protected
TextTreeConfiguration
get
textTreeConfiguration
{
TextTreeConfiguration
?
get
textTreeConfiguration
{
assert
(
style
!=
null
);
assert
(
style
!=
null
);
switch
(
style
)
{
switch
(
style
!
)
{
case
DiagnosticsTreeStyle
.
none
:
case
DiagnosticsTreeStyle
.
none
:
return
null
;
return
null
;
case
DiagnosticsTreeStyle
.
dense
:
case
DiagnosticsTreeStyle
.
dense
:
...
@@ -1710,7 +1708,6 @@ abstract class DiagnosticsNode {
...
@@ -1710,7 +1708,6 @@ abstract class DiagnosticsNode {
case
DiagnosticsTreeStyle
.
flat
:
case
DiagnosticsTreeStyle
.
flat
:
return
flatTextConfiguration
;
return
flatTextConfiguration
;
}
}
return
null
;
}
}
/// Returns a string representation of this node and its descendants.
/// Returns a string representation of this node and its descendants.
...
@@ -1735,8 +1732,8 @@ abstract class DiagnosticsNode {
...
@@ -1735,8 +1732,8 @@ abstract class DiagnosticsNode {
/// children.
/// children.
String
toStringDeep
({
String
toStringDeep
({
String
prefixLineOne
=
''
,
String
prefixLineOne
=
''
,
String
prefixOtherLines
,
String
?
prefixOtherLines
,
TextTreeConfiguration
parentConfiguration
,
TextTreeConfiguration
?
parentConfiguration
,
DiagnosticLevel
minLevel
=
DiagnosticLevel
.
debug
,
DiagnosticLevel
minLevel
=
DiagnosticLevel
.
debug
,
})
{
})
{
String
result
=
''
;
String
result
=
''
;
...
@@ -1817,13 +1814,13 @@ class StringProperty extends DiagnosticsProperty<String> {
...
@@ -1817,13 +1814,13 @@ class StringProperty extends DiagnosticsProperty<String> {
/// The [showName], [quoted], [style], and [level] arguments must not be null.
/// The [showName], [quoted], [style], and [level] arguments must not be null.
StringProperty
(
StringProperty
(
String
name
,
String
name
,
String
value
,
{
String
?
value
,
{
String
description
,
String
?
description
,
String
tooltip
,
String
?
tooltip
,
bool
showName
=
true
,
bool
showName
=
true
,
Object
defaultValue
=
kNoDefaultValue
,
Object
?
defaultValue
=
kNoDefaultValue
,
this
.
quoted
=
true
,
this
.
quoted
=
true
,
String
ifEmpty
,
String
?
ifEmpty
,
DiagnosticsTreeStyle
style
=
DiagnosticsTreeStyle
.
singleLine
,
DiagnosticsTreeStyle
style
=
DiagnosticsTreeStyle
.
singleLine
,
DiagnosticLevel
level
=
DiagnosticLevel
.
info
,
DiagnosticLevel
level
=
DiagnosticLevel
.
info
,
})
:
assert
(
showName
!=
null
),
})
:
assert
(
showName
!=
null
),
...
@@ -1846,15 +1843,15 @@ class StringProperty extends DiagnosticsProperty<String> {
...
@@ -1846,15 +1843,15 @@ class StringProperty extends DiagnosticsProperty<String> {
final
bool
quoted
;
final
bool
quoted
;
@override
@override
Map
<
String
,
Object
>
toJsonMap
(
DiagnosticsSerializationDelegate
delegate
)
{
Map
<
String
,
Object
?
>
toJsonMap
(
DiagnosticsSerializationDelegate
delegate
)
{
final
Map
<
String
,
Object
>
json
=
super
.
toJsonMap
(
delegate
);
final
Map
<
String
,
Object
?
>
json
=
super
.
toJsonMap
(
delegate
);
json
[
'quoted'
]
=
quoted
;
json
[
'quoted'
]
=
quoted
;
return
json
;
return
json
;
}
}
@override
@override
String
valueToString
({
TextTreeConfiguration
parentConfiguration
})
{
String
valueToString
({
TextTreeConfiguration
?
parentConfiguration
})
{
String
text
=
_description
??
value
;
String
?
text
=
_description
??
value
;
if
(
parentConfiguration
!=
null
&&
if
(
parentConfiguration
!=
null
&&
!
parentConfiguration
.
lineBreakProperties
&&
!
parentConfiguration
.
lineBreakProperties
&&
text
!=
null
)
{
text
!=
null
)
{
...
@@ -1868,7 +1865,7 @@ class StringProperty extends DiagnosticsProperty<String> {
...
@@ -1868,7 +1865,7 @@ class StringProperty extends DiagnosticsProperty<String> {
// An empty value would not appear empty after being surrounded with
// An empty value would not appear empty after being surrounded with
// quotes so we have to handle this case separately.
// quotes so we have to handle this case separately.
if
(
ifEmpty
!=
null
&&
text
.
isEmpty
)
if
(
ifEmpty
!=
null
&&
text
.
isEmpty
)
return
ifEmpty
;
return
ifEmpty
!
;
return
'"
$text
"'
;
return
'"
$text
"'
;
}
}
return
text
.
toString
();
return
text
.
toString
();
...
@@ -1878,12 +1875,12 @@ class StringProperty extends DiagnosticsProperty<String> {
...
@@ -1878,12 +1875,12 @@ class StringProperty extends DiagnosticsProperty<String> {
abstract
class
_NumProperty
<
T
extends
num
>
extends
DiagnosticsProperty
<
T
>
{
abstract
class
_NumProperty
<
T
extends
num
>
extends
DiagnosticsProperty
<
T
>
{
_NumProperty
(
_NumProperty
(
String
name
,
String
name
,
T
value
,
{
T
?
value
,
{
String
ifNull
,
String
?
ifNull
,
this
.
unit
,
this
.
unit
,
bool
showName
=
true
,
bool
showName
=
true
,
Object
defaultValue
=
kNoDefaultValue
,
Object
?
defaultValue
=
kNoDefaultValue
,
String
tooltip
,
String
?
tooltip
,
DiagnosticsTreeStyle
style
=
DiagnosticsTreeStyle
.
singleLine
,
DiagnosticsTreeStyle
style
=
DiagnosticsTreeStyle
.
singleLine
,
DiagnosticLevel
level
=
DiagnosticLevel
.
info
,
DiagnosticLevel
level
=
DiagnosticLevel
.
info
,
})
:
super
(
})
:
super
(
...
@@ -1900,11 +1897,11 @@ abstract class _NumProperty<T extends num> extends DiagnosticsProperty<T> {
...
@@ -1900,11 +1897,11 @@ abstract class _NumProperty<T extends num> extends DiagnosticsProperty<T> {
_NumProperty
.
lazy
(
_NumProperty
.
lazy
(
String
name
,
String
name
,
ComputePropertyValueCallback
<
T
>
computeValue
,
{
ComputePropertyValueCallback
<
T
>
computeValue
,
{
String
ifNull
,
String
?
ifNull
,
this
.
unit
,
this
.
unit
,
bool
showName
=
true
,
bool
showName
=
true
,
Object
defaultValue
=
kNoDefaultValue
,
Object
?
defaultValue
=
kNoDefaultValue
,
String
tooltip
,
String
?
tooltip
,
DiagnosticsTreeStyle
style
=
DiagnosticsTreeStyle
.
singleLine
,
DiagnosticsTreeStyle
style
=
DiagnosticsTreeStyle
.
singleLine
,
DiagnosticLevel
level
=
DiagnosticLevel
.
info
,
DiagnosticLevel
level
=
DiagnosticLevel
.
info
,
})
:
super
.
lazy
(
})
:
super
.
lazy
(
...
@@ -1919,8 +1916,8 @@ abstract class _NumProperty<T extends num> extends DiagnosticsProperty<T> {
...
@@ -1919,8 +1916,8 @@ abstract class _NumProperty<T extends num> extends DiagnosticsProperty<T> {
);
);
@override
@override
Map
<
String
,
Object
>
toJsonMap
(
DiagnosticsSerializationDelegate
delegate
)
{
Map
<
String
,
Object
?
>
toJsonMap
(
DiagnosticsSerializationDelegate
delegate
)
{
final
Map
<
String
,
Object
>
json
=
super
.
toJsonMap
(
delegate
);
final
Map
<
String
,
Object
?
>
json
=
super
.
toJsonMap
(
delegate
);
if
(
unit
!=
null
)
if
(
unit
!=
null
)
json
[
'unit'
]
=
unit
;
json
[
'unit'
]
=
unit
;
...
@@ -1933,13 +1930,13 @@ abstract class _NumProperty<T extends num> extends DiagnosticsProperty<T> {
...
@@ -1933,13 +1930,13 @@ abstract class _NumProperty<T extends num> extends DiagnosticsProperty<T> {
/// Unit must be acceptable to display immediately after a number with no
/// Unit must be acceptable to display immediately after a number with no
/// spaces. For example: 'physical pixels per logical pixel' should be a
/// spaces. For example: 'physical pixels per logical pixel' should be a
/// [tooltip] not a [unit].
/// [tooltip] not a [unit].
final
String
unit
;
final
String
?
unit
;
/// String describing just the numeric [value] without a unit suffix.
/// String describing just the numeric [value] without a unit suffix.
String
numberToString
();
String
numberToString
();
@override
@override
String
valueToString
({
TextTreeConfiguration
parentConfiguration
})
{
String
valueToString
({
TextTreeConfiguration
?
parentConfiguration
})
{
if
(
value
==
null
)
if
(
value
==
null
)
return
value
.
toString
();
return
value
.
toString
();
...
@@ -1955,11 +1952,11 @@ class DoubleProperty extends _NumProperty<double> {
...
@@ -1955,11 +1952,11 @@ class DoubleProperty extends _NumProperty<double> {
/// The [showName], [style], and [level] arguments must not be null.
/// The [showName], [style], and [level] arguments must not be null.
DoubleProperty
(
DoubleProperty
(
String
name
,
String
name
,
double
value
,
{
double
?
value
,
{
String
ifNull
,
String
?
ifNull
,
String
unit
,
String
?
unit
,
String
tooltip
,
String
?
tooltip
,
Object
defaultValue
=
kNoDefaultValue
,
Object
?
defaultValue
=
kNoDefaultValue
,
bool
showName
=
true
,
bool
showName
=
true
,
DiagnosticsTreeStyle
style
=
DiagnosticsTreeStyle
.
singleLine
,
DiagnosticsTreeStyle
style
=
DiagnosticsTreeStyle
.
singleLine
,
DiagnosticLevel
level
=
DiagnosticLevel
.
info
,
DiagnosticLevel
level
=
DiagnosticLevel
.
info
,
...
@@ -1987,11 +1984,11 @@ class DoubleProperty extends _NumProperty<double> {
...
@@ -1987,11 +1984,11 @@ class DoubleProperty extends _NumProperty<double> {
DoubleProperty
.
lazy
(
DoubleProperty
.
lazy
(
String
name
,
String
name
,
ComputePropertyValueCallback
<
double
>
computeValue
,
{
ComputePropertyValueCallback
<
double
>
computeValue
,
{
String
ifNull
,
String
?
ifNull
,
bool
showName
=
true
,
bool
showName
=
true
,
String
unit
,
String
?
unit
,
String
tooltip
,
String
?
tooltip
,
Object
defaultValue
=
kNoDefaultValue
,
Object
?
defaultValue
=
kNoDefaultValue
,
DiagnosticLevel
level
=
DiagnosticLevel
.
info
,
DiagnosticLevel
level
=
DiagnosticLevel
.
info
,
})
:
assert
(
showName
!=
null
),
})
:
assert
(
showName
!=
null
),
assert
(
level
!=
null
),
assert
(
level
!=
null
),
...
@@ -2019,11 +2016,11 @@ class IntProperty extends _NumProperty<int> {
...
@@ -2019,11 +2016,11 @@ class IntProperty extends _NumProperty<int> {
/// The [showName], [style], and [level] arguments must not be null.
/// The [showName], [style], and [level] arguments must not be null.
IntProperty
(
IntProperty
(
String
name
,
String
name
,
int
value
,
{
int
?
value
,
{
String
ifNull
,
String
?
ifNull
,
bool
showName
=
true
,
bool
showName
=
true
,
String
unit
,
String
?
unit
,
Object
defaultValue
=
kNoDefaultValue
,
Object
?
defaultValue
=
kNoDefaultValue
,
DiagnosticsTreeStyle
style
=
DiagnosticsTreeStyle
.
singleLine
,
DiagnosticsTreeStyle
style
=
DiagnosticsTreeStyle
.
singleLine
,
DiagnosticLevel
level
=
DiagnosticLevel
.
info
,
DiagnosticLevel
level
=
DiagnosticLevel
.
info
,
})
:
assert
(
showName
!=
null
),
})
:
assert
(
showName
!=
null
),
...
@@ -2057,10 +2054,10 @@ class PercentProperty extends DoubleProperty {
...
@@ -2057,10 +2054,10 @@ class PercentProperty extends DoubleProperty {
PercentProperty
(
PercentProperty
(
String
name
,
String
name
,
double
fraction
,
{
double
fraction
,
{
String
ifNull
,
String
?
ifNull
,
bool
showName
=
true
,
bool
showName
=
true
,
String
tooltip
,
String
?
tooltip
,
String
unit
,
String
?
unit
,
DiagnosticLevel
level
=
DiagnosticLevel
.
info
,
DiagnosticLevel
level
=
DiagnosticLevel
.
info
,
})
:
assert
(
showName
!=
null
),
})
:
assert
(
showName
!=
null
),
assert
(
level
!=
null
),
assert
(
level
!=
null
),
...
@@ -2075,7 +2072,7 @@ class PercentProperty extends DoubleProperty {
...
@@ -2075,7 +2072,7 @@ class PercentProperty extends DoubleProperty {
);
);
@override
@override
String
valueToString
({
TextTreeConfiguration
parentConfiguration
})
{
String
valueToString
({
TextTreeConfiguration
?
parentConfiguration
})
{
if
(
value
==
null
)
if
(
value
==
null
)
return
value
.
toString
();
return
value
.
toString
();
return
unit
!=
null
?
'
${numberToString()}
$unit
'
:
numberToString
();
return
unit
!=
null
?
'
${numberToString()}
$unit
'
:
numberToString
();
...
@@ -2083,9 +2080,10 @@ class PercentProperty extends DoubleProperty {
...
@@ -2083,9 +2080,10 @@ class PercentProperty extends DoubleProperty {
@override
@override
String
numberToString
()
{
String
numberToString
()
{
if
(
value
==
null
)
final
double
?
v
=
value
;
if
(
v
==
null
)
return
value
.
toString
();
return
value
.
toString
();
return
'
${(v
alue
.clamp(0.0, 1.0) * 100.0).toStringAsFixed(1)}
%'
;
return
'
${(v.clamp(0.0, 1.0) * 100.0).toStringAsFixed(1)}
%'
;
}
}
}
}
...
@@ -2137,11 +2135,11 @@ class FlagProperty extends DiagnosticsProperty<bool> {
...
@@ -2137,11 +2135,11 @@ class FlagProperty extends DiagnosticsProperty<bool> {
/// The [showName] and [level] arguments must not be null.
/// The [showName] and [level] arguments must not be null.
FlagProperty
(
FlagProperty
(
String
name
,
{
String
name
,
{
@required
bool
value
,
required
bool
?
value
,
this
.
ifTrue
,
this
.
ifTrue
,
this
.
ifFalse
,
this
.
ifFalse
,
bool
showName
=
false
,
bool
showName
=
false
,
Object
defaultValue
,
Object
?
defaultValue
,
DiagnosticLevel
level
=
DiagnosticLevel
.
info
,
DiagnosticLevel
level
=
DiagnosticLevel
.
info
,
})
:
assert
(
showName
!=
null
),
})
:
assert
(
showName
!=
null
),
assert
(
level
!=
null
),
assert
(
level
!=
null
),
...
@@ -2155,8 +2153,8 @@ class FlagProperty extends DiagnosticsProperty<bool> {
...
@@ -2155,8 +2153,8 @@ class FlagProperty extends DiagnosticsProperty<bool> {
);
);
@override
@override
Map
<
String
,
Object
>
toJsonMap
(
DiagnosticsSerializationDelegate
delegate
)
{
Map
<
String
,
Object
?
>
toJsonMap
(
DiagnosticsSerializationDelegate
delegate
)
{
final
Map
<
String
,
Object
>
json
=
super
.
toJsonMap
(
delegate
);
final
Map
<
String
,
Object
?
>
json
=
super
.
toJsonMap
(
delegate
);
if
(
ifTrue
!=
null
)
if
(
ifTrue
!=
null
)
json
[
'ifTrue'
]
=
ifTrue
;
json
[
'ifTrue'
]
=
ifTrue
;
if
(
ifFalse
!=
null
)
if
(
ifFalse
!=
null
)
...
@@ -2169,22 +2167,22 @@ class FlagProperty extends DiagnosticsProperty<bool> {
...
@@ -2169,22 +2167,22 @@ class FlagProperty extends DiagnosticsProperty<bool> {
///
///
/// If not specified and [value] equals true the property's priority [level]
/// If not specified and [value] equals true the property's priority [level]
/// will be [DiagnosticLevel.hidden].
/// will be [DiagnosticLevel.hidden].
final
String
ifTrue
;
final
String
?
ifTrue
;
/// Description to use if the property value is false.
/// Description to use if the property value is false.
///
///
/// If not specified and [value] equals false, the property's priority [level]
/// If not specified and [value] equals false, the property's priority [level]
/// will be [DiagnosticLevel.hidden].
/// will be [DiagnosticLevel.hidden].
final
String
ifFalse
;
final
String
?
ifFalse
;
@override
@override
String
valueToString
({
TextTreeConfiguration
parentConfiguration
})
{
String
valueToString
({
TextTreeConfiguration
?
parentConfiguration
})
{
if
(
value
==
true
)
{
if
(
value
==
true
)
{
if
(
ifTrue
!=
null
)
if
(
ifTrue
!=
null
)
return
ifTrue
;
return
ifTrue
!
;
}
else
if
(
value
==
false
)
{
}
else
if
(
value
==
false
)
{
if
(
ifFalse
!=
null
)
if
(
ifFalse
!=
null
)
return
ifFalse
;
return
ifFalse
!
;
}
}
return
super
.
valueToString
(
parentConfiguration:
parentConfiguration
);
return
super
.
valueToString
(
parentConfiguration:
parentConfiguration
);
}
}
...
@@ -2233,10 +2231,10 @@ class IterableProperty<T> extends DiagnosticsProperty<Iterable<T>> {
...
@@ -2233,10 +2231,10 @@ class IterableProperty<T> extends DiagnosticsProperty<Iterable<T>> {
/// The [style], [showName], [showSeparator], and [level] arguments must not be null.
/// The [style], [showName], [showSeparator], and [level] arguments must not be null.
IterableProperty
(
IterableProperty
(
String
name
,
String
name
,
Iterable
<
T
>
value
,
{
Iterable
<
T
>
?
value
,
{
Object
defaultValue
=
kNoDefaultValue
,
Object
?
defaultValue
=
kNoDefaultValue
,
String
ifNull
,
String
?
ifNull
,
String
ifEmpty
=
'[]'
,
String
?
ifEmpty
=
'[]'
,
DiagnosticsTreeStyle
style
=
DiagnosticsTreeStyle
.
singleLine
,
DiagnosticsTreeStyle
style
=
DiagnosticsTreeStyle
.
singleLine
,
bool
showName
=
true
,
bool
showName
=
true
,
bool
showSeparator
=
true
,
bool
showSeparator
=
true
,
...
@@ -2258,14 +2256,14 @@ class IterableProperty<T> extends DiagnosticsProperty<Iterable<T>> {
...
@@ -2258,14 +2256,14 @@ class IterableProperty<T> extends DiagnosticsProperty<Iterable<T>> {
);
);
@override
@override
String
valueToString
({
TextTreeConfiguration
parentConfiguration
})
{
String
valueToString
({
TextTreeConfiguration
?
parentConfiguration
})
{
if
(
value
==
null
)
if
(
value
==
null
)
return
value
.
toString
();
return
value
.
toString
();
if
(
value
.
isEmpty
)
if
(
value
!
.
isEmpty
)
return
ifEmpty
??
'[]'
;
return
ifEmpty
??
'[]'
;
final
Iterable
<
String
>
formattedValues
=
value
.
map
((
T
v
)
{
final
Iterable
<
String
>
formattedValues
=
value
!
.
map
((
T
v
)
{
if
(
T
==
double
&&
v
is
double
)
{
if
(
T
==
double
&&
v
is
double
)
{
return
debugFormatDouble
(
v
);
return
debugFormatDouble
(
v
);
}
else
{
}
else
{
...
@@ -2291,16 +2289,16 @@ class IterableProperty<T> extends DiagnosticsProperty<Iterable<T>> {
...
@@ -2291,16 +2289,16 @@ class IterableProperty<T> extends DiagnosticsProperty<Iterable<T>> {
/// null.
/// null.
@override
@override
DiagnosticLevel
get
level
{
DiagnosticLevel
get
level
{
if
(
ifEmpty
==
null
&&
value
!=
null
&&
value
.
isEmpty
&&
super
.
level
!=
DiagnosticLevel
.
hidden
)
if
(
ifEmpty
==
null
&&
value
!=
null
&&
value
!
.
isEmpty
&&
super
.
level
!=
DiagnosticLevel
.
hidden
)
return
DiagnosticLevel
.
fine
;
return
DiagnosticLevel
.
fine
;
return
super
.
level
;
return
super
.
level
;
}
}
@override
@override
Map
<
String
,
Object
>
toJsonMap
(
DiagnosticsSerializationDelegate
delegate
)
{
Map
<
String
,
Object
?
>
toJsonMap
(
DiagnosticsSerializationDelegate
delegate
)
{
final
Map
<
String
,
Object
>
json
=
super
.
toJsonMap
(
delegate
);
final
Map
<
String
,
Object
?
>
json
=
super
.
toJsonMap
(
delegate
);
if
(
value
!=
null
)
{
if
(
value
!=
null
)
{
json
[
'values'
]
=
value
.
map
<
String
>((
T
value
)
=>
value
.
toString
()).
toList
();
json
[
'values'
]
=
value
!
.
map
<
String
>((
T
value
)
=>
value
.
toString
()).
toList
();
}
}
return
json
;
return
json
;
}
}
...
@@ -2321,8 +2319,8 @@ class EnumProperty<T> extends DiagnosticsProperty<T> {
...
@@ -2321,8 +2319,8 @@ class EnumProperty<T> extends DiagnosticsProperty<T> {
/// The [level] argument must also not be null.
/// The [level] argument must also not be null.
EnumProperty
(
EnumProperty
(
String
name
,
String
name
,
T
value
,
{
T
?
value
,
{
Object
defaultValue
=
kNoDefaultValue
,
Object
?
defaultValue
=
kNoDefaultValue
,
DiagnosticLevel
level
=
DiagnosticLevel
.
info
,
DiagnosticLevel
level
=
DiagnosticLevel
.
info
,
})
:
assert
(
level
!=
null
),
})
:
assert
(
level
!=
null
),
super
(
super
(
...
@@ -2333,10 +2331,10 @@ class EnumProperty<T> extends DiagnosticsProperty<T> {
...
@@ -2333,10 +2331,10 @@ class EnumProperty<T> extends DiagnosticsProperty<T> {
);
);
@override
@override
String
valueToString
({
TextTreeConfiguration
parentConfiguration
})
{
String
valueToString
({
TextTreeConfiguration
?
parentConfiguration
})
{
if
(
value
==
null
)
if
(
value
==
null
)
return
value
.
toString
();
return
value
.
toString
();
return
describeEnum
(
value
);
return
describeEnum
(
value
!
);
}
}
}
}
...
@@ -2371,9 +2369,9 @@ class ObjectFlagProperty<T> extends DiagnosticsProperty<T> {
...
@@ -2371,9 +2369,9 @@ class ObjectFlagProperty<T> extends DiagnosticsProperty<T> {
/// least one of [ifPresent] and [ifNull] must not be null.
/// least one of [ifPresent] and [ifNull] must not be null.
ObjectFlagProperty
(
ObjectFlagProperty
(
String
name
,
String
name
,
T
value
,
{
T
?
value
,
{
this
.
ifPresent
,
this
.
ifPresent
,
String
ifNull
,
String
?
ifNull
,
bool
showName
=
false
,
bool
showName
=
false
,
DiagnosticLevel
level
=
DiagnosticLevel
.
info
,
DiagnosticLevel
level
=
DiagnosticLevel
.
info
,
})
:
assert
(
ifPresent
!=
null
||
ifNull
!=
null
),
})
:
assert
(
ifPresent
!=
null
||
ifNull
!=
null
),
...
@@ -2395,7 +2393,7 @@ class ObjectFlagProperty<T> extends DiagnosticsProperty<T> {
...
@@ -2395,7 +2393,7 @@ class ObjectFlagProperty<T> extends DiagnosticsProperty<T> {
/// The [name] and [level] arguments must not be null.
/// The [name] and [level] arguments must not be null.
ObjectFlagProperty
.
has
(
ObjectFlagProperty
.
has
(
String
name
,
String
name
,
T
value
,
{
T
?
value
,
{
DiagnosticLevel
level
=
DiagnosticLevel
.
info
,
DiagnosticLevel
level
=
DiagnosticLevel
.
info
,
})
:
assert
(
name
!=
null
),
})
:
assert
(
name
!=
null
),
assert
(
level
!=
null
),
assert
(
level
!=
null
),
...
@@ -2412,16 +2410,16 @@ class ObjectFlagProperty<T> extends DiagnosticsProperty<T> {
...
@@ -2412,16 +2410,16 @@ class ObjectFlagProperty<T> extends DiagnosticsProperty<T> {
/// If the property [value] is not null and [ifPresent] is null, the
/// If the property [value] is not null and [ifPresent] is null, the
/// [level] for the property is [DiagnosticLevel.hidden] and the description
/// [level] for the property is [DiagnosticLevel.hidden] and the description
/// from superclass is used.
/// from superclass is used.
final
String
ifPresent
;
final
String
?
ifPresent
;
@override
@override
String
valueToString
({
TextTreeConfiguration
parentConfiguration
})
{
String
valueToString
({
TextTreeConfiguration
?
parentConfiguration
})
{
if
(
value
!=
null
)
{
if
(
value
!=
null
)
{
if
(
ifPresent
!=
null
)
if
(
ifPresent
!=
null
)
return
ifPresent
;
return
ifPresent
!
;
}
else
{
}
else
{
if
(
ifNull
!=
null
)
if
(
ifNull
!=
null
)
return
ifNull
;
return
ifNull
!
;
}
}
return
super
.
valueToString
(
parentConfiguration:
parentConfiguration
);
return
super
.
valueToString
(
parentConfiguration:
parentConfiguration
);
}
}
...
@@ -2452,8 +2450,8 @@ class ObjectFlagProperty<T> extends DiagnosticsProperty<T> {
...
@@ -2452,8 +2450,8 @@ class ObjectFlagProperty<T> extends DiagnosticsProperty<T> {
}
}
@override
@override
Map
<
String
,
Object
>
toJsonMap
(
DiagnosticsSerializationDelegate
delegate
)
{
Map
<
String
,
Object
?
>
toJsonMap
(
DiagnosticsSerializationDelegate
delegate
)
{
final
Map
<
String
,
Object
>
json
=
super
.
toJsonMap
(
delegate
);
final
Map
<
String
,
Object
?
>
json
=
super
.
toJsonMap
(
delegate
);
if
(
ifPresent
!=
null
)
if
(
ifPresent
!=
null
)
json
[
'ifPresent'
]
=
ifPresent
;
json
[
'ifPresent'
]
=
ifPresent
;
return
json
;
return
json
;
...
@@ -2490,7 +2488,7 @@ class FlagsSummary<T> extends DiagnosticsProperty<Map<String, T>> {
...
@@ -2490,7 +2488,7 @@ class FlagsSummary<T> extends DiagnosticsProperty<Map<String, T>> {
FlagsSummary
(
FlagsSummary
(
String
name
,
String
name
,
Map
<
String
,
T
>
value
,
{
Map
<
String
,
T
>
value
,
{
String
ifEmpty
,
String
?
ifEmpty
,
bool
showName
=
true
,
bool
showName
=
true
,
bool
showSeparator
=
true
,
bool
showSeparator
=
true
,
DiagnosticLevel
level
=
DiagnosticLevel
.
info
,
DiagnosticLevel
level
=
DiagnosticLevel
.
info
,
...
@@ -2508,10 +2506,13 @@ class FlagsSummary<T> extends DiagnosticsProperty<Map<String, T>> {
...
@@ -2508,10 +2506,13 @@ class FlagsSummary<T> extends DiagnosticsProperty<Map<String, T>> {
);
);
@override
@override
String
valueToString
({
TextTreeConfiguration
parentConfiguration
})
{
Map
<
String
,
T
>
get
value
=>
super
.
value
as
Map
<
String
,
T
>;
@override
String
valueToString
({
TextTreeConfiguration
?
parentConfiguration
})
{
assert
(
value
!=
null
);
assert
(
value
!=
null
);
if
(!
_hasNonNullEntry
()
&&
ifEmpty
!=
null
)
if
(!
_hasNonNullEntry
()
&&
ifEmpty
!=
null
)
return
ifEmpty
;
return
ifEmpty
!
;
final
Iterable
<
String
>
formattedValues
=
_formattedValues
();
final
Iterable
<
String
>
formattedValues
=
_formattedValues
();
if
(
parentConfiguration
!=
null
&&
!
parentConfiguration
.
lineBreakProperties
)
{
if
(
parentConfiguration
!=
null
&&
!
parentConfiguration
.
lineBreakProperties
)
{
...
@@ -2536,14 +2537,14 @@ class FlagsSummary<T> extends DiagnosticsProperty<Map<String, T>> {
...
@@ -2536,14 +2537,14 @@ class FlagsSummary<T> extends DiagnosticsProperty<Map<String, T>> {
}
}
@override
@override
Map
<
String
,
Object
>
toJsonMap
(
DiagnosticsSerializationDelegate
delegate
)
{
Map
<
String
,
Object
?
>
toJsonMap
(
DiagnosticsSerializationDelegate
delegate
)
{
final
Map
<
String
,
Object
>
json
=
super
.
toJsonMap
(
delegate
);
final
Map
<
String
,
Object
?
>
json
=
super
.
toJsonMap
(
delegate
);
if
(
value
.
isNotEmpty
)
if
(
value
.
isNotEmpty
)
json
[
'values'
]
=
_formattedValues
().
toList
();
json
[
'values'
]
=
_formattedValues
().
toList
();
return
json
;
return
json
;
}
}
bool
_hasNonNullEntry
()
=>
value
.
values
.
any
((
Object
o
)
=>
o
!=
null
);
bool
_hasNonNullEntry
()
=>
value
.
values
.
any
((
T
o
)
=>
o
!=
null
);
// An iterable of each entry's description in [value].
// An iterable of each entry's description in [value].
//
//
...
@@ -2585,17 +2586,17 @@ class DiagnosticsProperty<T> extends DiagnosticsNode {
...
@@ -2585,17 +2586,17 @@ class DiagnosticsProperty<T> extends DiagnosticsNode {
/// level. For example, if the property value is null and [missingIfNull] is
/// level. For example, if the property value is null and [missingIfNull] is
/// true, [level] is raised to [DiagnosticLevel.warning].
/// true, [level] is raised to [DiagnosticLevel.warning].
DiagnosticsProperty
(
DiagnosticsProperty
(
String
name
,
String
?
name
,
T
value
,
{
T
?
value
,
{
String
description
,
String
?
description
,
String
ifNull
,
String
?
ifNull
,
this
.
ifEmpty
,
this
.
ifEmpty
,
bool
showName
=
true
,
bool
showName
=
true
,
bool
showSeparator
=
true
,
bool
showSeparator
=
true
,
this
.
defaultValue
=
kNoDefaultValue
,
this
.
defaultValue
=
kNoDefaultValue
,
this
.
tooltip
,
this
.
tooltip
,
this
.
missingIfNull
=
false
,
this
.
missingIfNull
=
false
,
String
linePrefix
,
String
?
linePrefix
,
this
.
expandableValue
=
false
,
this
.
expandableValue
=
false
,
this
.
allowWrap
=
true
,
this
.
allowWrap
=
true
,
this
.
allowNameWrap
=
true
,
this
.
allowNameWrap
=
true
,
...
@@ -2632,10 +2633,10 @@ class DiagnosticsProperty<T> extends DiagnosticsNode {
...
@@ -2632,10 +2633,10 @@ class DiagnosticsProperty<T> extends DiagnosticsNode {
/// level. For example, if calling `computeValue` throws an exception, [level]
/// level. For example, if calling `computeValue` throws an exception, [level]
/// will always return [DiagnosticLevel.error].
/// will always return [DiagnosticLevel.error].
DiagnosticsProperty
.
lazy
(
DiagnosticsProperty
.
lazy
(
String
name
,
String
?
name
,
ComputePropertyValueCallback
<
T
>
computeValue
,
{
ComputePropertyValueCallback
<
T
>
computeValue
,
{
String
description
,
String
?
description
,
String
ifNull
,
String
?
ifNull
,
this
.
ifEmpty
,
this
.
ifEmpty
,
bool
showName
=
true
,
bool
showName
=
true
,
bool
showSeparator
=
true
,
bool
showSeparator
=
true
,
...
@@ -2666,7 +2667,7 @@ class DiagnosticsProperty<T> extends DiagnosticsNode {
...
@@ -2666,7 +2667,7 @@ class DiagnosticsProperty<T> extends DiagnosticsNode {
style:
style
,
style:
style
,
);
);
final
String
_description
;
final
String
?
_description
;
/// Whether to expose properties and children of the value as properties and
/// Whether to expose properties and children of the value as properties and
/// children.
/// children.
...
@@ -2679,9 +2680,9 @@ class DiagnosticsProperty<T> extends DiagnosticsNode {
...
@@ -2679,9 +2680,9 @@ class DiagnosticsProperty<T> extends DiagnosticsNode {
final
bool
allowNameWrap
;
final
bool
allowNameWrap
;
@override
@override
Map
<
String
,
Object
>
toJsonMap
(
DiagnosticsSerializationDelegate
delegate
)
{
Map
<
String
,
Object
?
>
toJsonMap
(
DiagnosticsSerializationDelegate
delegate
)
{
final
T
v
=
value
;
final
T
?
v
=
value
;
List
<
Map
<
String
,
Object
>>
properties
;
List
<
Map
<
String
,
Object
?>>?
properties
;
if
(
delegate
.
expandPropertyValues
&&
delegate
.
includeProperties
&&
v
is
Diagnosticable
&&
getProperties
().
isEmpty
)
{
if
(
delegate
.
expandPropertyValues
&&
delegate
.
includeProperties
&&
v
is
Diagnosticable
&&
getProperties
().
isEmpty
)
{
// Exclude children for expanded nodes to avoid cycles.
// Exclude children for expanded nodes to avoid cycles.
delegate
=
delegate
.
copyWith
(
subtreeDepth:
0
,
includeProperties:
false
);
delegate
=
delegate
.
copyWith
(
subtreeDepth:
0
,
includeProperties:
false
);
...
@@ -2691,7 +2692,7 @@ class DiagnosticsProperty<T> extends DiagnosticsNode {
...
@@ -2691,7 +2692,7 @@ class DiagnosticsProperty<T> extends DiagnosticsNode {
delegate
,
delegate
,
);
);
}
}
final
Map
<
String
,
Object
>
json
=
super
.
toJsonMap
(
delegate
);
final
Map
<
String
,
Object
?
>
json
=
super
.
toJsonMap
(
delegate
);
if
(
properties
!=
null
)
{
if
(
properties
!=
null
)
{
json
[
'properties'
]
=
properties
;
json
[
'properties'
]
=
properties
;
}
}
...
@@ -2732,28 +2733,28 @@ class DiagnosticsProperty<T> extends DiagnosticsNode {
...
@@ -2732,28 +2733,28 @@ class DiagnosticsProperty<T> extends DiagnosticsNode {
/// `parentConfiguration` specifies how the parent is rendered as text art.
/// `parentConfiguration` specifies how the parent is rendered as text art.
/// For example, if the parent places all properties on one line, the value
/// For example, if the parent places all properties on one line, the value
/// of the property should be displayed without line breaks if possible.
/// of the property should be displayed without line breaks if possible.
String
valueToString
({
TextTreeConfiguration
parentConfiguration
})
{
String
valueToString
({
TextTreeConfiguration
?
parentConfiguration
})
{
final
T
v
=
value
;
final
T
?
v
=
value
;
// DiagnosticableTree values are shown using the shorter toStringShort()
// DiagnosticableTree values are shown using the shorter toStringShort()
// instead of the longer toString() because the toString() for a
// instead of the longer toString() because the toString() for a
// DiagnosticableTree value is likely too large to be useful.
// DiagnosticableTree value is likely too large to be useful.
return
(
v
is
DiagnosticableTree
?
v
.
toStringShort
()
:
v
.
toString
())
??
''
;
return
v
is
DiagnosticableTree
?
v
.
toStringShort
()
:
v
.
toString
()
;
}
}
@override
@override
String
toDescription
({
TextTreeConfiguration
parentConfiguration
})
{
String
toDescription
({
TextTreeConfiguration
?
parentConfiguration
})
{
if
(
_description
!=
null
)
if
(
_description
!=
null
)
return
_addTooltip
(
_description
);
return
_addTooltip
(
_description
!
);
if
(
exception
!=
null
)
if
(
exception
!=
null
)
return
'EXCEPTION (
${exception.runtimeType}
)'
;
return
'EXCEPTION (
${exception.runtimeType}
)'
;
if
(
ifNull
!=
null
&&
value
==
null
)
if
(
ifNull
!=
null
&&
value
==
null
)
return
_addTooltip
(
ifNull
);
return
_addTooltip
(
ifNull
!
);
String
result
=
valueToString
(
parentConfiguration:
parentConfiguration
);
String
result
=
valueToString
(
parentConfiguration:
parentConfiguration
);
if
(
result
.
isEmpty
&&
ifEmpty
!=
null
)
if
(
result
.
isEmpty
&&
ifEmpty
!=
null
)
result
=
ifEmpty
;
result
=
ifEmpty
!
;
return
_addTooltip
(
result
);
return
_addTooltip
(
result
);
}
}
...
@@ -2768,10 +2769,10 @@ class DiagnosticsProperty<T> extends DiagnosticsNode {
...
@@ -2768,10 +2769,10 @@ class DiagnosticsProperty<T> extends DiagnosticsNode {
}
}
/// Description if the property [value] is null.
/// Description if the property [value] is null.
final
String
ifNull
;
final
String
?
ifNull
;
/// Description if the property description would otherwise be empty.
/// Description if the property description would otherwise be empty.
final
String
ifEmpty
;
final
String
?
ifEmpty
;
/// Optional tooltip typically describing the property.
/// Optional tooltip typically describing the property.
///
///
...
@@ -2779,7 +2780,7 @@ class DiagnosticsProperty<T> extends DiagnosticsNode {
...
@@ -2779,7 +2780,7 @@ class DiagnosticsProperty<T> extends DiagnosticsNode {
///
///
/// If present, the tooltip is added in parenthesis after the raw value when
/// If present, the tooltip is added in parenthesis after the raw value when
/// generating the string description.
/// generating the string description.
final
String
tooltip
;
final
String
?
tooltip
;
/// Whether a [value] of null causes the property to have [level]
/// Whether a [value] of null causes the property to have [level]
/// [DiagnosticLevel.warning] warning that the property is missing a [value].
/// [DiagnosticLevel.warning] warning that the property is missing a [value].
...
@@ -2809,21 +2810,21 @@ class DiagnosticsProperty<T> extends DiagnosticsNode {
...
@@ -2809,21 +2810,21 @@ class DiagnosticsProperty<T> extends DiagnosticsNode {
///
///
/// * [valueToString], which converts the property value to a string.
/// * [valueToString], which converts the property value to a string.
@override
@override
T
get
value
{
T
?
get
value
{
_maybeCacheValue
();
_maybeCacheValue
();
return
_value
;
return
_value
;
}
}
T
_value
;
T
?
_value
;
bool
_valueComputed
;
bool
_valueComputed
;
Object
_exception
;
Object
?
_exception
;
/// Exception thrown if accessing the property [value] threw an exception.
/// Exception thrown if accessing the property [value] threw an exception.
///
///
/// Returns null if computing the property value did not throw an exception.
/// Returns null if computing the property value did not throw an exception.
Object
get
exception
{
Object
?
get
exception
{
_maybeCacheValue
();
_maybeCacheValue
();
return
_exception
;
return
_exception
;
}
}
...
@@ -2835,7 +2836,7 @@ class DiagnosticsProperty<T> extends DiagnosticsNode {
...
@@ -2835,7 +2836,7 @@ class DiagnosticsProperty<T> extends DiagnosticsNode {
_valueComputed
=
true
;
_valueComputed
=
true
;
assert
(
_computeValue
!=
null
);
assert
(
_computeValue
!=
null
);
try
{
try
{
_value
=
_computeValue
();
_value
=
_computeValue
!
();
}
catch
(
exception
)
{
}
catch
(
exception
)
{
_exception
=
exception
;
_exception
=
exception
;
_value
=
null
;
_value
=
null
;
...
@@ -2847,7 +2848,7 @@ class DiagnosticsProperty<T> extends DiagnosticsNode {
...
@@ -2847,7 +2848,7 @@ class DiagnosticsProperty<T> extends DiagnosticsNode {
/// value is uninteresting.
/// value is uninteresting.
///
///
/// [defaultValue] has type [T] or is [kNoDefaultValue].
/// [defaultValue] has type [T] or is [kNoDefaultValue].
final
Object
defaultValue
;
final
Object
?
defaultValue
;
final
DiagnosticLevel
_defaultLevel
;
final
DiagnosticLevel
_defaultLevel
;
...
@@ -2879,12 +2880,12 @@ class DiagnosticsProperty<T> extends DiagnosticsNode {
...
@@ -2879,12 +2880,12 @@ class DiagnosticsProperty<T> extends DiagnosticsNode {
return
_defaultLevel
;
return
_defaultLevel
;
}
}
final
ComputePropertyValueCallback
<
T
>
_computeValue
;
final
ComputePropertyValueCallback
<
T
>
?
_computeValue
;
@override
@override
List
<
DiagnosticsNode
>
getProperties
()
{
List
<
DiagnosticsNode
>
getProperties
()
{
if
(
expandableValue
)
{
if
(
expandableValue
)
{
final
T
object
=
value
;
final
T
?
object
=
value
;
if
(
object
is
DiagnosticsNode
)
{
if
(
object
is
DiagnosticsNode
)
{
return
object
.
getProperties
();
return
object
.
getProperties
();
}
}
...
@@ -2898,7 +2899,7 @@ class DiagnosticsProperty<T> extends DiagnosticsNode {
...
@@ -2898,7 +2899,7 @@ class DiagnosticsProperty<T> extends DiagnosticsNode {
@override
@override
List
<
DiagnosticsNode
>
getChildren
()
{
List
<
DiagnosticsNode
>
getChildren
()
{
if
(
expandableValue
)
{
if
(
expandableValue
)
{
final
T
object
=
value
;
final
T
?
object
=
value
;
if
(
object
is
DiagnosticsNode
)
{
if
(
object
is
DiagnosticsNode
)
{
return
object
.
getChildren
();
return
object
.
getChildren
();
}
}
...
@@ -2917,9 +2918,9 @@ class DiagnosticableNode<T extends Diagnosticable> extends DiagnosticsNode {
...
@@ -2917,9 +2918,9 @@ class DiagnosticableNode<T extends Diagnosticable> extends DiagnosticsNode {
///
///
/// The [value] argument must not be null.
/// The [value] argument must not be null.
DiagnosticableNode
({
DiagnosticableNode
({
String
name
,
String
?
name
,
@
required
this
.
value
,
required
this
.
value
,
@required
DiagnosticsTreeStyle
style
,
required
DiagnosticsTreeStyle
?
style
,
})
:
assert
(
value
!=
null
),
})
:
assert
(
value
!=
null
),
super
(
super
(
name:
name
,
name:
name
,
...
@@ -2929,19 +2930,19 @@ class DiagnosticableNode<T extends Diagnosticable> extends DiagnosticsNode {
...
@@ -2929,19 +2930,19 @@ class DiagnosticableNode<T extends Diagnosticable> extends DiagnosticsNode {
@override
@override
final
T
value
;
final
T
value
;
DiagnosticPropertiesBuilder
_cachedBuilder
;
DiagnosticPropertiesBuilder
?
_cachedBuilder
;
/// Retrieve the [DiagnosticPropertiesBuilder] of current node.
/// Retrieve the [DiagnosticPropertiesBuilder] of current node.
///
///
/// It will cache the result to prevent duplicate operation.
/// It will cache the result to prevent duplicate operation.
DiagnosticPropertiesBuilder
get
builder
{
DiagnosticPropertiesBuilder
?
get
builder
{
if
(
kReleaseMode
)
{
if
(
kReleaseMode
)
{
return
null
;
return
null
;
}
else
{
}
else
{
assert
(()
{
assert
(()
{
if
(
_cachedBuilder
==
null
)
{
if
(
_cachedBuilder
==
null
)
{
_cachedBuilder
=
DiagnosticPropertiesBuilder
();
_cachedBuilder
=
DiagnosticPropertiesBuilder
();
value
?.
debugFillProperties
(
_cachedBuilder
);
value
.
debugFillProperties
(
_cachedBuilder
!
);
}
}
return
true
;
return
true
;
}());
}());
...
@@ -2951,14 +2952,14 @@ class DiagnosticableNode<T extends Diagnosticable> extends DiagnosticsNode {
...
@@ -2951,14 +2952,14 @@ class DiagnosticableNode<T extends Diagnosticable> extends DiagnosticsNode {
@override
@override
DiagnosticsTreeStyle
get
style
{
DiagnosticsTreeStyle
get
style
{
return
kReleaseMode
?
DiagnosticsTreeStyle
.
none
:
super
.
style
??
builder
.
defaultDiagnosticsTreeStyle
;
return
kReleaseMode
?
DiagnosticsTreeStyle
.
none
:
super
.
style
??
builder
!
.
defaultDiagnosticsTreeStyle
;
}
}
@override
@override
String
get
emptyBodyDescription
=>
(
kReleaseMode
||
kProfileMode
)
?
''
:
builder
.
emptyBodyDescription
;
String
?
get
emptyBodyDescription
=>
(
kReleaseMode
||
kProfileMode
)
?
''
:
builder
!
.
emptyBodyDescription
;
@override
@override
List
<
DiagnosticsNode
>
getProperties
()
=>
(
kReleaseMode
||
kProfileMode
)
?
const
<
DiagnosticsNode
>[]
:
builder
.
properties
;
List
<
DiagnosticsNode
>
getProperties
()
=>
(
kReleaseMode
||
kProfileMode
)
?
const
<
DiagnosticsNode
>[]
:
builder
!
.
properties
;
@override
@override
List
<
DiagnosticsNode
>
getChildren
()
{
List
<
DiagnosticsNode
>
getChildren
()
{
...
@@ -2966,7 +2967,7 @@ class DiagnosticableNode<T extends Diagnosticable> extends DiagnosticsNode {
...
@@ -2966,7 +2967,7 @@ class DiagnosticableNode<T extends Diagnosticable> extends DiagnosticsNode {
}
}
@override
@override
String
toDescription
({
TextTreeConfiguration
parentConfiguration
})
{
String
toDescription
({
TextTreeConfiguration
?
parentConfiguration
})
{
String
result
=
''
;
String
result
=
''
;
assert
(()
{
assert
(()
{
result
=
value
.
toStringShort
();
result
=
value
.
toStringShort
();
...
@@ -2980,9 +2981,9 @@ class DiagnosticableNode<T extends Diagnosticable> extends DiagnosticsNode {
...
@@ -2980,9 +2981,9 @@ class DiagnosticableNode<T extends Diagnosticable> extends DiagnosticsNode {
class
DiagnosticableTreeNode
extends
DiagnosticableNode
<
DiagnosticableTree
>
{
class
DiagnosticableTreeNode
extends
DiagnosticableNode
<
DiagnosticableTree
>
{
/// Creates a [DiagnosticableTreeNode].
/// Creates a [DiagnosticableTreeNode].
DiagnosticableTreeNode
({
DiagnosticableTreeNode
({
String
name
,
String
?
name
,
@
required
DiagnosticableTree
value
,
required
DiagnosticableTree
value
,
@required
DiagnosticsTreeStyle
style
,
required
DiagnosticsTreeStyle
?
style
,
})
:
super
(
})
:
super
(
name:
name
,
name:
name
,
value:
value
,
value:
value
,
...
@@ -2990,16 +2991,12 @@ class DiagnosticableTreeNode extends DiagnosticableNode<DiagnosticableTree> {
...
@@ -2990,16 +2991,12 @@ class DiagnosticableTreeNode extends DiagnosticableNode<DiagnosticableTree> {
);
);
@override
@override
List
<
DiagnosticsNode
>
getChildren
()
{
List
<
DiagnosticsNode
>
getChildren
()
=>
value
.
debugDescribeChildren
();
if
(
value
!=
null
)
return
value
.
debugDescribeChildren
();
return
const
<
DiagnosticsNode
>[];
}
}
}
/// Returns a 5 character long hexadecimal string generated from
/// Returns a 5 character long hexadecimal string generated from
/// [Object.hashCode]'s 20 least-significant bits.
/// [Object.hashCode]'s 20 least-significant bits.
String
shortHash
(
Object
object
)
{
String
shortHash
(
Object
?
object
)
{
return
object
.
hashCode
.
toUnsigned
(
20
).
toRadixString
(
16
).
padLeft
(
5
,
'0'
);
return
object
.
hashCode
.
toUnsigned
(
20
).
toRadixString
(
16
).
padLeft
(
5
,
'0'
);
}
}
...
@@ -3012,7 +3009,7 @@ String shortHash(Object object) {
...
@@ -3012,7 +3009,7 @@ String shortHash(Object object) {
/// distinguish instances of the same class (hash collisions are
/// distinguish instances of the same class (hash collisions are
/// possible, but rare enough that its use in debug output is useful).
/// possible, but rare enough that its use in debug output is useful).
/// * [Object.runtimeType], the [Type] of an object.
/// * [Object.runtimeType], the [Type] of an object.
String
describeIdentity
(
Object
object
)
=>
'
${objectRuntimeType(object, '<optimized out>')}
#
${shortHash(object)}
'
;
String
describeIdentity
(
Object
?
object
)
=>
'
${objectRuntimeType(object, '<optimized out>')}
#
${shortHash(object)}
'
;
// This method exists as a workaround for https://github.com/dart-lang/sdk/issues/30021
// This method exists as a workaround for https://github.com/dart-lang/sdk/issues/30021
/// Returns a short description of an enum value.
/// Returns a short description of an enum value.
...
@@ -3064,7 +3061,7 @@ class DiagnosticPropertiesBuilder {
...
@@ -3064,7 +3061,7 @@ class DiagnosticPropertiesBuilder {
DiagnosticsTreeStyle
defaultDiagnosticsTreeStyle
=
DiagnosticsTreeStyle
.
sparse
;
DiagnosticsTreeStyle
defaultDiagnosticsTreeStyle
=
DiagnosticsTreeStyle
.
sparse
;
/// Description to show if the node has no displayed properties or children.
/// Description to show if the node has no displayed properties or children.
String
emptyBodyDescription
;
String
?
emptyBodyDescription
;
}
}
// Examples can assume:
// Examples can assume:
...
@@ -3105,7 +3102,7 @@ mixin Diagnosticable {
...
@@ -3105,7 +3102,7 @@ mixin Diagnosticable {
@override
@override
String
toString
({
DiagnosticLevel
minLevel
=
DiagnosticLevel
.
info
})
{
String
toString
({
DiagnosticLevel
minLevel
=
DiagnosticLevel
.
info
})
{
String
fullString
;
String
?
fullString
;
assert
(()
{
assert
(()
{
fullString
=
toDiagnosticsNode
(
style:
DiagnosticsTreeStyle
.
singleLine
).
toString
(
minLevel:
minLevel
);
fullString
=
toDiagnosticsNode
(
style:
DiagnosticsTreeStyle
.
singleLine
).
toString
(
minLevel:
minLevel
);
return
true
;
return
true
;
...
@@ -3122,7 +3119,7 @@ mixin Diagnosticable {
...
@@ -3122,7 +3119,7 @@ mixin Diagnosticable {
/// Typically the [style] argument is only specified to indicate an atypical
/// Typically the [style] argument is only specified to indicate an atypical
/// relationship between the parent and the node. For example, pass
/// relationship between the parent and the node. For example, pass
/// [DiagnosticsTreeStyle.offstage] to indicate that a node is offstage.
/// [DiagnosticsTreeStyle.offstage] to indicate that a node is offstage.
DiagnosticsNode
toDiagnosticsNode
({
String
name
,
DiagnosticsTreeStyle
style
})
{
DiagnosticsNode
toDiagnosticsNode
({
String
?
name
,
DiagnosticsTreeStyle
?
style
})
{
return
DiagnosticableNode
<
Diagnosticable
>(
return
DiagnosticableNode
<
Diagnosticable
>(
name:
name
,
name:
name
,
value:
this
,
value:
this
,
...
@@ -3377,14 +3374,14 @@ abstract class DiagnosticableTree with Diagnosticable {
...
@@ -3377,14 +3374,14 @@ abstract class DiagnosticableTree with Diagnosticable {
///
///
/// * [toString], for a brief description of the object.
/// * [toString], for a brief description of the object.
/// * [toStringDeep], for a description of the subtree rooted at this object.
/// * [toStringDeep], for a description of the subtree rooted at this object.
String
toStringShallow
({
String
?
toStringShallow
({
String
joiner
=
', '
,
String
joiner
=
', '
,
DiagnosticLevel
minLevel
=
DiagnosticLevel
.
debug
,
DiagnosticLevel
minLevel
=
DiagnosticLevel
.
debug
,
})
{
})
{
if
(
kReleaseMode
)
{
if
(
kReleaseMode
)
{
return
toString
();
return
toString
();
}
}
String
shallowString
;
String
?
shallowString
;
assert
(()
{
assert
(()
{
final
StringBuffer
result
=
StringBuffer
();
final
StringBuffer
result
=
StringBuffer
();
result
.
write
(
toString
());
result
.
write
(
toString
());
...
@@ -3421,7 +3418,7 @@ abstract class DiagnosticableTree with Diagnosticable {
...
@@ -3421,7 +3418,7 @@ abstract class DiagnosticableTree with Diagnosticable {
/// children.
/// children.
String
toStringDeep
({
String
toStringDeep
({
String
prefixLineOne
=
''
,
String
prefixLineOne
=
''
,
String
prefixOtherLines
,
String
?
prefixOtherLines
,
DiagnosticLevel
minLevel
=
DiagnosticLevel
.
debug
,
DiagnosticLevel
minLevel
=
DiagnosticLevel
.
debug
,
})
{
})
{
return
toDiagnosticsNode
().
toStringDeep
(
prefixLineOne:
prefixLineOne
,
prefixOtherLines:
prefixOtherLines
,
minLevel:
minLevel
);
return
toDiagnosticsNode
().
toStringDeep
(
prefixLineOne:
prefixLineOne
,
prefixOtherLines:
prefixOtherLines
,
minLevel:
minLevel
);
...
@@ -3431,7 +3428,7 @@ abstract class DiagnosticableTree with Diagnosticable {
...
@@ -3431,7 +3428,7 @@ abstract class DiagnosticableTree with Diagnosticable {
String
toStringShort
()
=>
describeIdentity
(
this
);
String
toStringShort
()
=>
describeIdentity
(
this
);
@override
@override
DiagnosticsNode
toDiagnosticsNode
({
String
name
,
DiagnosticsTreeStyle
style
})
{
DiagnosticsNode
toDiagnosticsNode
({
String
?
name
,
DiagnosticsTreeStyle
?
style
})
{
return
DiagnosticableTreeNode
(
return
DiagnosticableTreeNode
(
name:
name
,
name:
name
,
value:
this
,
value:
this
,
...
@@ -3470,14 +3467,14 @@ mixin DiagnosticableTreeMixin implements DiagnosticableTree {
...
@@ -3470,14 +3467,14 @@ mixin DiagnosticableTreeMixin implements DiagnosticableTree {
}
}
@override
@override
String
toStringShallow
({
String
?
toStringShallow
({
String
joiner
=
', '
,
String
joiner
=
', '
,
DiagnosticLevel
minLevel
=
DiagnosticLevel
.
debug
,
DiagnosticLevel
minLevel
=
DiagnosticLevel
.
debug
,
})
{
})
{
if
(
kReleaseMode
)
{
if
(
kReleaseMode
)
{
return
toString
();
return
toString
();
}
}
String
shallowString
;
String
?
shallowString
;
assert
(()
{
assert
(()
{
final
StringBuffer
result
=
StringBuffer
();
final
StringBuffer
result
=
StringBuffer
();
result
.
write
(
toStringShort
());
result
.
write
(
toStringShort
());
...
@@ -3497,7 +3494,7 @@ mixin DiagnosticableTreeMixin implements DiagnosticableTree {
...
@@ -3497,7 +3494,7 @@ mixin DiagnosticableTreeMixin implements DiagnosticableTree {
@override
@override
String
toStringDeep
({
String
toStringDeep
({
String
prefixLineOne
=
''
,
String
prefixLineOne
=
''
,
String
prefixOtherLines
,
String
?
prefixOtherLines
,
DiagnosticLevel
minLevel
=
DiagnosticLevel
.
debug
,
DiagnosticLevel
minLevel
=
DiagnosticLevel
.
debug
,
})
{
})
{
return
toDiagnosticsNode
().
toStringDeep
(
prefixLineOne:
prefixLineOne
,
prefixOtherLines:
prefixOtherLines
,
minLevel:
minLevel
);
return
toDiagnosticsNode
().
toStringDeep
(
prefixLineOne:
prefixLineOne
,
prefixOtherLines:
prefixOtherLines
,
minLevel:
minLevel
);
...
@@ -3507,7 +3504,7 @@ mixin DiagnosticableTreeMixin implements DiagnosticableTree {
...
@@ -3507,7 +3504,7 @@ mixin DiagnosticableTreeMixin implements DiagnosticableTree {
String
toStringShort
()
=>
describeIdentity
(
this
);
String
toStringShort
()
=>
describeIdentity
(
this
);
@override
@override
DiagnosticsNode
toDiagnosticsNode
({
String
name
,
DiagnosticsTreeStyle
style
})
{
DiagnosticsNode
toDiagnosticsNode
({
String
?
name
,
DiagnosticsTreeStyle
?
style
})
{
return
DiagnosticableTreeNode
(
return
DiagnosticableTreeNode
(
name:
name
,
name:
name
,
value:
this
,
value:
this
,
...
@@ -3531,13 +3528,13 @@ class DiagnosticsBlock extends DiagnosticsNode {
...
@@ -3531,13 +3528,13 @@ class DiagnosticsBlock extends DiagnosticsNode {
/// Creates a diagnostic with properties specified by [properties] and
/// Creates a diagnostic with properties specified by [properties] and
/// children specified by [children].
/// children specified by [children].
DiagnosticsBlock
({
DiagnosticsBlock
({
String
name
,
String
?
name
,
DiagnosticsTreeStyle
style
=
DiagnosticsTreeStyle
.
whitespace
,
DiagnosticsTreeStyle
style
=
DiagnosticsTreeStyle
.
whitespace
,
bool
showName
=
true
,
bool
showName
=
true
,
bool
showSeparator
=
true
,
bool
showSeparator
=
true
,
String
linePrefix
,
String
?
linePrefix
,
this
.
value
,
this
.
value
,
String
description
,
String
?
description
,
this
.
level
=
DiagnosticLevel
.
info
,
this
.
level
=
DiagnosticLevel
.
info
,
this
.
allowTruncate
=
false
,
this
.
allowTruncate
=
false
,
List
<
DiagnosticsNode
>
children
=
const
<
DiagnosticsNode
>[],
List
<
DiagnosticsNode
>
children
=
const
<
DiagnosticsNode
>[],
...
@@ -3558,9 +3555,9 @@ class DiagnosticsBlock extends DiagnosticsNode {
...
@@ -3558,9 +3555,9 @@ class DiagnosticsBlock extends DiagnosticsNode {
@override
@override
final
DiagnosticLevel
level
;
final
DiagnosticLevel
level
;
final
String
_description
;
final
String
?
_description
;
@override
@override
final
Object
value
;
final
Object
?
value
;
@override
@override
final
bool
allowTruncate
;
final
bool
allowTruncate
;
...
@@ -3572,7 +3569,7 @@ class DiagnosticsBlock extends DiagnosticsNode {
...
@@ -3572,7 +3569,7 @@ class DiagnosticsBlock extends DiagnosticsNode {
List
<
DiagnosticsNode
>
getProperties
()
=>
_properties
;
List
<
DiagnosticsNode
>
getProperties
()
=>
_properties
;
@override
@override
String
toDescription
({
TextTreeConfiguration
parentConfiguration
})
=>
_description
;
String
?
toDescription
({
TextTreeConfiguration
?
parentConfiguration
})
=>
_description
;
}
}
/// A delegate that configures how a hierarchy of [DiagnosticsNode]s should be
/// A delegate that configures how a hierarchy of [DiagnosticsNode]s should be
...
@@ -3597,7 +3594,7 @@ abstract class DiagnosticsSerializationDelegate {
...
@@ -3597,7 +3594,7 @@ abstract class DiagnosticsSerializationDelegate {
///
///
/// This method is called for every [DiagnosticsNode] that's included in
/// This method is called for every [DiagnosticsNode] that's included in
/// the serialization.
/// the serialization.
Map
<
String
,
Object
>
additionalNodeProperties
(
DiagnosticsNode
node
);
Map
<
String
,
Object
?
>
additionalNodeProperties
(
DiagnosticsNode
node
);
/// Filters the list of [DiagnosticsNode]s that will be included as children
/// Filters the list of [DiagnosticsNode]s that will be included as children
/// for the given `owner` node.
/// for the given `owner` node.
...
@@ -3635,7 +3632,7 @@ abstract class DiagnosticsSerializationDelegate {
...
@@ -3635,7 +3632,7 @@ abstract class DiagnosticsSerializationDelegate {
/// result that are not included in the current serialization.
/// result that are not included in the current serialization.
///
///
/// By default, `nodes` is returned as-is.
/// By default, `nodes` is returned as-is.
List
<
DiagnosticsNode
>
truncateNodesList
(
List
<
DiagnosticsNode
>
nodes
,
DiagnosticsNode
owner
);
List
<
DiagnosticsNode
>
truncateNodesList
(
List
<
DiagnosticsNode
>
nodes
,
DiagnosticsNode
?
owner
);
/// Returns the [DiagnosticsSerializationDelegate] to be used
/// Returns the [DiagnosticsSerializationDelegate] to be used
/// for adding the provided [DiagnosticsNode] to the serialization.
/// for adding the provided [DiagnosticsNode] to the serialization.
...
@@ -3689,8 +3686,8 @@ class _DefaultDiagnosticsSerializationDelegate implements DiagnosticsSerializati
...
@@ -3689,8 +3686,8 @@ class _DefaultDiagnosticsSerializationDelegate implements DiagnosticsSerializati
});
});
@override
@override
Map
<
String
,
Object
>
additionalNodeProperties
(
DiagnosticsNode
node
)
{
Map
<
String
,
Object
?
>
additionalNodeProperties
(
DiagnosticsNode
node
)
{
return
const
<
String
,
Object
>{};
return
const
<
String
,
Object
?
>{};
}
}
@override
@override
...
@@ -3718,12 +3715,12 @@ class _DefaultDiagnosticsSerializationDelegate implements DiagnosticsSerializati
...
@@ -3718,12 +3715,12 @@ class _DefaultDiagnosticsSerializationDelegate implements DiagnosticsSerializati
final
int
subtreeDepth
;
final
int
subtreeDepth
;
@override
@override
List
<
DiagnosticsNode
>
truncateNodesList
(
List
<
DiagnosticsNode
>
nodes
,
DiagnosticsNode
owner
)
{
List
<
DiagnosticsNode
>
truncateNodesList
(
List
<
DiagnosticsNode
>
nodes
,
DiagnosticsNode
?
owner
)
{
return
nodes
;
return
nodes
;
}
}
@override
@override
DiagnosticsSerializationDelegate
copyWith
({
int
subtreeDepth
,
bool
includeProperties
})
{
DiagnosticsSerializationDelegate
copyWith
({
int
?
subtreeDepth
,
bool
?
includeProperties
})
{
return
_DefaultDiagnosticsSerializationDelegate
(
return
_DefaultDiagnosticsSerializationDelegate
(
subtreeDepth:
subtreeDepth
??
this
.
subtreeDepth
,
subtreeDepth:
subtreeDepth
??
this
.
subtreeDepth
,
includeProperties:
includeProperties
??
this
.
includeProperties
,
includeProperties:
includeProperties
??
this
.
includeProperties
,
...
...
packages/flutter/lib/src/foundation/isolates.dart
View file @
978a2e7b
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:async'
;
import
'dart:async'
;
import
'_isolates_io.dart'
import
'_isolates_io.dart'
...
@@ -20,7 +18,7 @@ import '_isolates_io.dart'
...
@@ -20,7 +18,7 @@ import '_isolates_io.dart'
typedef
ComputeCallback
<
Q
,
R
>
=
FutureOr
<
R
>
Function
(
Q
message
);
typedef
ComputeCallback
<
Q
,
R
>
=
FutureOr
<
R
>
Function
(
Q
message
);
// The signature of [compute].
// The signature of [compute].
typedef
_ComputeImpl
=
Future
<
R
>
Function
<
Q
,
R
>(
ComputeCallback
<
Q
,
R
>
callback
,
Q
message
,
{
String
debugLabel
});
typedef
_ComputeImpl
=
Future
<
R
>
Function
<
Q
,
R
>(
ComputeCallback
<
Q
,
R
>
callback
,
Q
message
,
{
String
?
debugLabel
});
/// Spawn an isolate, run `callback` on that isolate, passing it `message`, and
/// Spawn an isolate, run `callback` on that isolate, passing it `message`, and
/// (eventually) return the value returned by `callback`.
/// (eventually) return the value returned by `callback`.
...
...
packages/flutter/lib/src/foundation/key.dart
View file @
978a2e7b
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:ui'
show
hashValues
;
import
'dart:ui'
show
hashValues
;
import
'package:meta/meta.dart'
;
import
'package:meta/meta.dart'
;
...
...
packages/flutter/lib/src/foundation/licenses.dart
View file @
978a2e7b
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:async'
;
import
'dart:async'
;
import
'package:meta/meta.dart'
show
visibleForTesting
;
import
'package:meta/meta.dart'
show
visibleForTesting
;
...
@@ -49,7 +47,7 @@ abstract class LicenseEntry {
...
@@ -49,7 +47,7 @@ abstract class LicenseEntry {
const
LicenseEntry
();
const
LicenseEntry
();
/// The names of the packages that this license entry applies to.
/// The names of the packages that this license entry applies to.
Iterable
<
String
>
get
packages
;
Iterable
<
String
>
?
get
packages
;
/// The paragraphs of the license, each as a [LicenseParagraph] consisting of
/// The paragraphs of the license, each as a [LicenseParagraph] consisting of
/// a string and some formatting information. Paragraphs can include newline
/// a string and some formatting information. Paragraphs can include newline
...
@@ -125,7 +123,7 @@ class LicenseEntryWithLineBreaks extends LicenseEntry {
...
@@ -125,7 +123,7 @@ class LicenseEntryWithLineBreaks extends LicenseEntry {
const
LicenseEntryWithLineBreaks
(
this
.
packages
,
this
.
text
);
const
LicenseEntryWithLineBreaks
(
this
.
packages
,
this
.
text
);
@override
@override
final
List
<
String
>
packages
;
final
List
<
String
>
?
packages
;
/// The text of the license.
/// The text of the license.
///
///
...
@@ -148,7 +146,7 @@ class LicenseEntryWithLineBreaks extends LicenseEntry {
...
@@ -148,7 +146,7 @@ class LicenseEntryWithLineBreaks extends LicenseEntry {
int
currentPosition
=
0
;
int
currentPosition
=
0
;
int
lastLineIndent
=
0
;
int
lastLineIndent
=
0
;
int
currentLineIndent
=
0
;
int
currentLineIndent
=
0
;
int
currentParagraphIndentation
;
int
?
currentParagraphIndentation
;
_LicenseEntryWithLineBreaksParserState
state
=
_LicenseEntryWithLineBreaksParserState
.
beforeParagraph
;
_LicenseEntryWithLineBreaksParserState
state
=
_LicenseEntryWithLineBreaksParserState
.
beforeParagraph
;
final
List
<
String
>
lines
=
<
String
>[];
final
List
<
String
>
lines
=
<
String
>[];
...
@@ -160,7 +158,7 @@ class LicenseEntryWithLineBreaks extends LicenseEntry {
...
@@ -160,7 +158,7 @@ class LicenseEntryWithLineBreaks extends LicenseEntry {
LicenseParagraph
getParagraph
()
{
LicenseParagraph
getParagraph
()
{
assert
(
lines
.
isNotEmpty
);
assert
(
lines
.
isNotEmpty
);
assert
(
currentParagraphIndentation
!=
null
);
assert
(
currentParagraphIndentation
!=
null
);
final
LicenseParagraph
result
=
LicenseParagraph
(
lines
.
join
(
' '
),
currentParagraphIndentation
);
final
LicenseParagraph
result
=
LicenseParagraph
(
lines
.
join
(
' '
),
currentParagraphIndentation
!
);
assert
(
result
.
text
.
trimLeft
()
==
result
.
text
);
assert
(
result
.
text
.
trimLeft
()
==
result
.
text
);
assert
(
result
.
text
.
isNotEmpty
);
assert
(
result
.
text
.
isNotEmpty
);
lines
.
clear
();
lines
.
clear
();
...
@@ -295,7 +293,7 @@ class LicenseRegistry {
...
@@ -295,7 +293,7 @@ class LicenseRegistry {
// ignore: unused_element
// ignore: unused_element
LicenseRegistry
.
_
();
LicenseRegistry
.
_
();
static
List
<
LicenseEntryCollector
>
_collectors
;
static
List
<
LicenseEntryCollector
>
?
_collectors
;
/// Adds licenses to the registry.
/// Adds licenses to the registry.
///
///
...
@@ -306,7 +304,7 @@ class LicenseRegistry {
...
@@ -306,7 +304,7 @@ class LicenseRegistry {
/// licenses, the closure will not be called.
/// licenses, the closure will not be called.
static
void
addLicense
(
LicenseEntryCollector
collector
)
{
static
void
addLicense
(
LicenseEntryCollector
collector
)
{
_collectors
??=
<
LicenseEntryCollector
>[];
_collectors
??=
<
LicenseEntryCollector
>[];
_collectors
.
add
(
collector
);
_collectors
!
.
add
(
collector
);
}
}
/// Returns the licenses that have been registered.
/// Returns the licenses that have been registered.
...
@@ -315,7 +313,7 @@ class LicenseRegistry {
...
@@ -315,7 +313,7 @@ class LicenseRegistry {
static
Stream
<
LicenseEntry
>
get
licenses
async
*
{
static
Stream
<
LicenseEntry
>
get
licenses
async
*
{
if
(
_collectors
==
null
)
if
(
_collectors
==
null
)
return
;
return
;
for
(
final
LicenseEntryCollector
collector
in
_collectors
)
for
(
final
LicenseEntryCollector
collector
in
_collectors
!
)
yield
*
collector
();
yield
*
collector
();
}
}
...
...
packages/flutter/lib/src/foundation/node.dart
View file @
978a2e7b
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:meta/meta.dart'
;
import
'package:meta/meta.dart'
;
// This file gets mutated by //dev/devicelab/bin/tasks/flutter_test_performance.dart
// This file gets mutated by //dev/devicelab/bin/tasks/flutter_test_performance.dart
...
@@ -71,8 +69,8 @@ class AbstractNode {
...
@@ -71,8 +69,8 @@ class AbstractNode {
/// The owner for this node (null if unattached).
/// The owner for this node (null if unattached).
///
///
/// The entire subtree that this node belongs to will have the same owner.
/// The entire subtree that this node belongs to will have the same owner.
Object
get
owner
=>
_owner
;
Object
?
get
owner
=>
_owner
;
Object
_owner
;
Object
?
_owner
;
/// Whether this node is in a tree whose root is attached to something.
/// Whether this node is in a tree whose root is attached to something.
///
///
...
@@ -107,12 +105,12 @@ class AbstractNode {
...
@@ -107,12 +105,12 @@ class AbstractNode {
void
detach
()
{
void
detach
()
{
assert
(
_owner
!=
null
);
assert
(
_owner
!=
null
);
_owner
=
null
;
_owner
=
null
;
assert
(
parent
==
null
||
attached
==
parent
.
attached
);
assert
(
parent
==
null
||
attached
==
parent
!
.
attached
);
}
}
/// The parent of this node in the tree.
/// The parent of this node in the tree.
AbstractNode
get
parent
=>
_parent
;
AbstractNode
?
get
parent
=>
_parent
;
AbstractNode
_parent
;
AbstractNode
?
_parent
;
/// Mark the given node as being a child of this node.
/// Mark the given node as being a child of this node.
///
///
...
@@ -125,13 +123,13 @@ class AbstractNode {
...
@@ -125,13 +123,13 @@ class AbstractNode {
assert
(()
{
assert
(()
{
AbstractNode
node
=
this
;
AbstractNode
node
=
this
;
while
(
node
.
parent
!=
null
)
while
(
node
.
parent
!=
null
)
node
=
node
.
parent
;
node
=
node
.
parent
!
;
assert
(
node
!=
child
);
// indicates we are about to create a cycle
assert
(
node
!=
child
);
// indicates we are about to create a cycle
return
true
;
return
true
;
}());
}());
child
.
_parent
=
this
;
child
.
_parent
=
this
;
if
(
attached
)
if
(
attached
)
child
.
attach
(
_owner
);
child
.
attach
(
_owner
!
);
redepthChild
(
child
);
redepthChild
(
child
);
}
}
...
...
packages/flutter/lib/src/foundation/object.dart
View file @
978a2e7b
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
/// Framework code should use this method in favor of calling `toString` on
/// Framework code should use this method in favor of calling `toString` on
/// [Object.runtimeType].
/// [Object.runtimeType].
///
///
...
@@ -11,7 +9,7 @@
...
@@ -11,7 +9,7 @@
/// negatively impact performance. If asserts are enabled, this method will
/// negatively impact performance. If asserts are enabled, this method will
/// return `object.runtimeType.toString()`; otherwise, it will return the
/// return `object.runtimeType.toString()`; otherwise, it will return the
/// [optimizedValue], which must be a simple constant string.
/// [optimizedValue], which must be a simple constant string.
String
objectRuntimeType
(
Object
object
,
String
optimizedValue
)
{
String
objectRuntimeType
(
Object
?
object
,
String
optimizedValue
)
{
assert
(()
{
assert
(()
{
optimizedValue
=
object
.
runtimeType
.
toString
();
optimizedValue
=
object
.
runtimeType
.
toString
();
return
true
;
return
true
;
...
...
packages/flutter/lib/src/foundation/observer_list.dart
View file @
978a2e7b
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:collection'
;
import
'dart:collection'
;
/// A list optimized for the observer pattern when there are small numbers of
/// A list optimized for the observer pattern when there are small numbers of
...
@@ -29,7 +27,7 @@ import 'dart:collection';
...
@@ -29,7 +27,7 @@ import 'dart:collection';
class
ObserverList
<
T
>
extends
Iterable
<
T
>
{
class
ObserverList
<
T
>
extends
Iterable
<
T
>
{
final
List
<
T
>
_list
=
<
T
>[];
final
List
<
T
>
_list
=
<
T
>[];
bool
_isDirty
=
false
;
bool
_isDirty
=
false
;
HashSet
<
T
>
_set
;
late
final
HashSet
<
T
>
_set
=
HashSet
<
T
>()
;
/// Adds an item to the end of this list.
/// Adds an item to the end of this list.
///
///
...
@@ -46,21 +44,17 @@ class ObserverList<T> extends Iterable<T> {
...
@@ -46,21 +44,17 @@ class ObserverList<T> extends Iterable<T> {
/// Returns whether the item was present in the list.
/// Returns whether the item was present in the list.
bool
remove
(
T
item
)
{
bool
remove
(
T
item
)
{
_isDirty
=
true
;
_isDirty
=
true
;
_set
?
.
clear
();
// Clear the set so that we don't leak items.
_set
.
clear
();
// Clear the set so that we don't leak items.
return
_list
.
remove
(
item
);
return
_list
.
remove
(
item
);
}
}
@override
@override
bool
contains
(
Object
element
)
{
bool
contains
(
Object
?
element
)
{
if
(
_list
.
length
<
3
)
if
(
_list
.
length
<
3
)
return
_list
.
contains
(
element
);
return
_list
.
contains
(
element
);
if
(
_isDirty
)
{
if
(
_isDirty
)
{
if
(
_set
==
null
)
{
_set
=
HashSet
<
T
>.
from
(
_list
);
}
else
{
_set
.
addAll
(
_list
);
_set
.
addAll
(
_list
);
}
_isDirty
=
false
;
_isDirty
=
false
;
}
}
...
@@ -107,7 +101,7 @@ class HashedObserverList<T> extends Iterable<T> {
...
@@ -107,7 +101,7 @@ class HashedObserverList<T> extends Iterable<T> {
///
///
/// Returns whether the item was present in the list.
/// Returns whether the item was present in the list.
bool
remove
(
T
item
)
{
bool
remove
(
T
item
)
{
final
int
value
=
_map
[
item
];
final
int
?
value
=
_map
[
item
];
if
(
value
==
null
)
{
if
(
value
==
null
)
{
return
false
;
return
false
;
}
}
...
@@ -120,7 +114,7 @@ class HashedObserverList<T> extends Iterable<T> {
...
@@ -120,7 +114,7 @@ class HashedObserverList<T> extends Iterable<T> {
}
}
@override
@override
bool
contains
(
Object
element
)
=>
_map
.
containsKey
(
element
);
bool
contains
(
Object
?
element
)
=>
_map
.
containsKey
(
element
);
@override
@override
Iterator
<
T
>
get
iterator
=>
_map
.
keys
.
iterator
;
Iterator
<
T
>
get
iterator
=>
_map
.
keys
.
iterator
;
...
...
packages/flutter/lib/src/foundation/platform.dart
View file @
978a2e7b
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'_platform_io.dart'
import
'_platform_io.dart'
if
(
dart
.
library
.
html
)
'_platform_web.dart'
as
_platform
;
if
(
dart
.
library
.
html
)
'_platform_web.dart'
as
_platform
;
...
@@ -79,4 +77,4 @@ enum TargetPlatform {
...
@@ -79,4 +77,4 @@ enum TargetPlatform {
/// button, which will make those widgets unusable since iOS has no such button.
/// button, which will make those widgets unusable since iOS has no such button.
///
///
/// In general, therefore, this property should not be used in release builds.
/// In general, therefore, this property should not be used in release builds.
TargetPlatform
debugDefaultTargetPlatformOverride
;
TargetPlatform
?
debugDefaultTargetPlatformOverride
;
packages/flutter/lib/src/foundation/print.dart
View file @
978a2e7b
...
@@ -2,13 +2,11 @@
...
@@ -2,13 +2,11 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:async'
;
import
'dart:async'
;
import
'dart:collection'
;
import
'dart:collection'
;
/// Signature for [debugPrint] implementations.
/// Signature for [debugPrint] implementations.
typedef
DebugPrintCallback
=
void
Function
(
String
message
,
{
int
wrapWidth
});
typedef
DebugPrintCallback
=
void
Function
(
String
?
message
,
{
int
?
wrapWidth
});
/// Prints a message to the console, which you can access using the "flutter"
/// Prints a message to the console, which you can access using the "flutter"
/// tool's "logs" command ("flutter logs").
/// tool's "logs" command ("flutter logs").
...
@@ -32,8 +30,8 @@ DebugPrintCallback debugPrint = debugPrintThrottled;
...
@@ -32,8 +30,8 @@ DebugPrintCallback debugPrint = debugPrintThrottled;
/// Alternative implementation of [debugPrint] that does not throttle.
/// Alternative implementation of [debugPrint] that does not throttle.
/// Used by tests.
/// Used by tests.
void
debugPrintSynchronously
(
String
message
,
{
int
wrapWidth
})
{
void
debugPrintSynchronously
(
String
?
message
,
{
int
?
wrapWidth
})
{
if
(
wrapWidth
!=
null
)
{
if
(
message
!=
null
&&
wrapWidth
!=
null
)
{
print
(
message
.
split
(
'
\n
'
).
expand
<
String
>((
String
line
)
=>
debugWordWrap
(
line
,
wrapWidth
)).
join
(
'
\n
'
));
print
(
message
.
split
(
'
\n
'
).
expand
<
String
>((
String
line
)
=>
debugWordWrap
(
line
,
wrapWidth
)).
join
(
'
\n
'
));
}
else
{
}
else
{
print
(
message
);
print
(
message
);
...
@@ -42,7 +40,7 @@ void debugPrintSynchronously(String message, { int wrapWidth }) {
...
@@ -42,7 +40,7 @@ void debugPrintSynchronously(String message, { int wrapWidth }) {
/// Implementation of [debugPrint] that throttles messages. This avoids dropping
/// Implementation of [debugPrint] that throttles messages. This avoids dropping
/// messages on platforms that rate-limit their logging (for example, Android).
/// messages on platforms that rate-limit their logging (for example, Android).
void
debugPrintThrottled
(
String
message
,
{
int
wrapWidth
})
{
void
debugPrintThrottled
(
String
?
message
,
{
int
?
wrapWidth
})
{
final
List
<
String
>
messageLines
=
message
?.
split
(
'
\n
'
)
??
<
String
>[
'null'
];
final
List
<
String
>
messageLines
=
message
?.
split
(
'
\n
'
)
??
<
String
>[
'null'
];
if
(
wrapWidth
!=
null
)
{
if
(
wrapWidth
!=
null
)
{
_debugPrintBuffer
.
addAll
(
messageLines
.
expand
<
String
>((
String
line
)
=>
debugWordWrap
(
line
,
wrapWidth
)));
_debugPrintBuffer
.
addAll
(
messageLines
.
expand
<
String
>((
String
line
)
=>
debugWordWrap
(
line
,
wrapWidth
)));
...
@@ -57,7 +55,7 @@ const int _kDebugPrintCapacity = 12 * 1024;
...
@@ -57,7 +55,7 @@ const int _kDebugPrintCapacity = 12 * 1024;
const
Duration
_kDebugPrintPauseTime
=
Duration
(
seconds:
1
);
const
Duration
_kDebugPrintPauseTime
=
Duration
(
seconds:
1
);
final
Queue
<
String
>
_debugPrintBuffer
=
Queue
<
String
>();
final
Queue
<
String
>
_debugPrintBuffer
=
Queue
<
String
>();
final
Stopwatch
_debugPrintStopwatch
=
Stopwatch
();
final
Stopwatch
_debugPrintStopwatch
=
Stopwatch
();
Completer
<
void
>
_debugPrintCompleter
;
Completer
<
void
>
?
_debugPrintCompleter
;
bool
_debugPrintScheduled
=
false
;
bool
_debugPrintScheduled
=
false
;
void
_debugPrintTask
(
)
{
void
_debugPrintTask
(
)
{
_debugPrintScheduled
=
false
;
_debugPrintScheduled
=
false
;
...
@@ -112,15 +110,15 @@ Iterable<String> debugWordWrap(String message, int width, { String wrapIndent =
...
@@ -112,15 +110,15 @@ Iterable<String> debugWordWrap(String message, int width, { String wrapIndent =
yield
message
;
yield
message
;
return
;
return
;
}
}
final
Match
prefixMatch
=
_indentPattern
.
matchAsPrefix
(
message
);
final
Match
prefixMatch
=
_indentPattern
.
matchAsPrefix
(
message
)
!
;
final
String
prefix
=
wrapIndent
+
' '
*
prefixMatch
.
group
(
0
).
length
;
final
String
prefix
=
wrapIndent
+
' '
*
prefixMatch
.
group
(
0
)
!
.
length
;
int
start
=
0
;
int
start
=
0
;
int
startForLengthCalculations
=
0
;
int
startForLengthCalculations
=
0
;
bool
addPrefix
=
false
;
bool
addPrefix
=
false
;
int
index
=
prefix
.
length
;
int
index
=
prefix
.
length
;
_WordWrapParseMode
mode
=
_WordWrapParseMode
.
inSpace
;
_WordWrapParseMode
mode
=
_WordWrapParseMode
.
inSpace
;
int
lastWordStart
;
late
int
lastWordStart
;
int
lastWordEnd
;
int
?
lastWordEnd
;
while
(
true
)
{
while
(
true
)
{
switch
(
mode
)
{
switch
(
mode
)
{
case
_WordWrapParseMode
.
inSpace
:
// at start of break point (or start of line); can't break until next break
case
_WordWrapParseMode
.
inSpace
:
// at start of break point (or start of line); can't break until next break
...
...
packages/flutter/lib/src/foundation/serialization.dart
View file @
978a2e7b
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:typed_data'
;
import
'dart:typed_data'
;
import
'package:typed_data/typed_buffers.dart'
show
Uint8Buffer
;
import
'package:typed_data/typed_buffers.dart'
show
Uint8Buffer
;
...
@@ -16,86 +14,86 @@ import 'package:typed_data/typed_buffers.dart' show Uint8Buffer;
...
@@ -16,86 +14,86 @@ import 'package:typed_data/typed_buffers.dart' show Uint8Buffer;
/// The byte order used is [Endian.host] throughout.
/// The byte order used is [Endian.host] throughout.
class
WriteBuffer
{
class
WriteBuffer
{
/// Creates an interface for incrementally building a [ByteData] instance.
/// Creates an interface for incrementally building a [ByteData] instance.
WriteBuffer
()
{
WriteBuffer
()
_buffer
=
Uint8Buffer
();
:
_buffer
=
Uint8Buffer
(),
_eightBytes
=
ByteData
(
8
);
_eightBytes
=
ByteData
(
8
)
{
_eightBytesAsList
=
_eightBytes
.
buffer
.
asUint8List
();
_eightBytesAsList
=
_eightBytes
.
buffer
.
asUint8List
();
}
}
Uint8Buffer
_buffer
;
Uint8Buffer
?
_buffer
;
ByteData
_eightBytes
;
final
ByteData
_eightBytes
;
Uint8List
_eightBytesAsList
;
late
Uint8List
_eightBytesAsList
;
/// Write a Uint8 into the buffer.
/// Write a Uint8 into the buffer.
void
putUint8
(
int
byte
)
{
void
putUint8
(
int
byte
)
{
_buffer
.
add
(
byte
);
_buffer
!
.
add
(
byte
);
}
}
/// Write a Uint16 into the buffer.
/// Write a Uint16 into the buffer.
void
putUint16
(
int
value
,
{
Endian
endian
})
{
void
putUint16
(
int
value
,
{
Endian
?
endian
})
{
_eightBytes
.
setUint16
(
0
,
value
,
endian
??
Endian
.
host
);
_eightBytes
.
setUint16
(
0
,
value
,
endian
??
Endian
.
host
);
_buffer
.
addAll
(
_eightBytesAsList
,
0
,
2
);
_buffer
!
.
addAll
(
_eightBytesAsList
,
0
,
2
);
}
}
/// Write a Uint32 into the buffer.
/// Write a Uint32 into the buffer.
void
putUint32
(
int
value
,
{
Endian
endian
})
{
void
putUint32
(
int
value
,
{
Endian
?
endian
})
{
_eightBytes
.
setUint32
(
0
,
value
,
endian
??
Endian
.
host
);
_eightBytes
.
setUint32
(
0
,
value
,
endian
??
Endian
.
host
);
_buffer
.
addAll
(
_eightBytesAsList
,
0
,
4
);
_buffer
!
.
addAll
(
_eightBytesAsList
,
0
,
4
);
}
}
/// Write an Int32 into the buffer.
/// Write an Int32 into the buffer.
void
putInt32
(
int
value
,
{
Endian
endian
})
{
void
putInt32
(
int
value
,
{
Endian
?
endian
})
{
_eightBytes
.
setInt32
(
0
,
value
,
endian
??
Endian
.
host
);
_eightBytes
.
setInt32
(
0
,
value
,
endian
??
Endian
.
host
);
_buffer
.
addAll
(
_eightBytesAsList
,
0
,
4
);
_buffer
!
.
addAll
(
_eightBytesAsList
,
0
,
4
);
}
}
/// Write an Int64 into the buffer.
/// Write an Int64 into the buffer.
void
putInt64
(
int
value
,
{
Endian
endian
})
{
void
putInt64
(
int
value
,
{
Endian
?
endian
})
{
_eightBytes
.
setInt64
(
0
,
value
,
endian
??
Endian
.
host
);
_eightBytes
.
setInt64
(
0
,
value
,
endian
??
Endian
.
host
);
_buffer
.
addAll
(
_eightBytesAsList
,
0
,
8
);
_buffer
!
.
addAll
(
_eightBytesAsList
,
0
,
8
);
}
}
/// Write an Float64 into the buffer.
/// Write an Float64 into the buffer.
void
putFloat64
(
double
value
,
{
Endian
endian
})
{
void
putFloat64
(
double
value
,
{
Endian
?
endian
})
{
_alignTo
(
8
);
_alignTo
(
8
);
_eightBytes
.
setFloat64
(
0
,
value
,
endian
??
Endian
.
host
);
_eightBytes
.
setFloat64
(
0
,
value
,
endian
??
Endian
.
host
);
_buffer
.
addAll
(
_eightBytesAsList
);
_buffer
!
.
addAll
(
_eightBytesAsList
);
}
}
/// Write all the values from a [Uint8List] into the buffer.
/// Write all the values from a [Uint8List] into the buffer.
void
putUint8List
(
Uint8List
list
)
{
void
putUint8List
(
Uint8List
list
)
{
_buffer
.
addAll
(
list
);
_buffer
!
.
addAll
(
list
);
}
}
/// Write all the values from an [Int32List] into the buffer.
/// Write all the values from an [Int32List] into the buffer.
void
putInt32List
(
Int32List
list
)
{
void
putInt32List
(
Int32List
list
)
{
_alignTo
(
4
);
_alignTo
(
4
);
_buffer
.
addAll
(
list
.
buffer
.
asUint8List
(
list
.
offsetInBytes
,
4
*
list
.
length
));
_buffer
!
.
addAll
(
list
.
buffer
.
asUint8List
(
list
.
offsetInBytes
,
4
*
list
.
length
));
}
}
/// Write all the values from an [Int64List] into the buffer.
/// Write all the values from an [Int64List] into the buffer.
void
putInt64List
(
Int64List
list
)
{
void
putInt64List
(
Int64List
list
)
{
_alignTo
(
8
);
_alignTo
(
8
);
_buffer
.
addAll
(
list
.
buffer
.
asUint8List
(
list
.
offsetInBytes
,
8
*
list
.
length
));
_buffer
!
.
addAll
(
list
.
buffer
.
asUint8List
(
list
.
offsetInBytes
,
8
*
list
.
length
));
}
}
/// Write all the values from a [Float64List] into the buffer.
/// Write all the values from a [Float64List] into the buffer.
void
putFloat64List
(
Float64List
list
)
{
void
putFloat64List
(
Float64List
list
)
{
_alignTo
(
8
);
_alignTo
(
8
);
_buffer
.
addAll
(
list
.
buffer
.
asUint8List
(
list
.
offsetInBytes
,
8
*
list
.
length
));
_buffer
!
.
addAll
(
list
.
buffer
.
asUint8List
(
list
.
offsetInBytes
,
8
*
list
.
length
));
}
}
void
_alignTo
(
int
alignment
)
{
void
_alignTo
(
int
alignment
)
{
final
int
mod
=
_buffer
.
length
%
alignment
;
final
int
mod
=
_buffer
!
.
length
%
alignment
;
if
(
mod
!=
0
)
{
if
(
mod
!=
0
)
{
for
(
int
i
=
0
;
i
<
alignment
-
mod
;
i
++)
for
(
int
i
=
0
;
i
<
alignment
-
mod
;
i
++)
_buffer
.
add
(
0
);
_buffer
!
.
add
(
0
);
}
}
}
}
/// Finalize and return the written [ByteData].
/// Finalize and return the written [ByteData].
ByteData
done
()
{
ByteData
done
()
{
final
ByteData
result
=
_buffer
.
buffer
.
asByteData
(
0
,
_buffer
.
lengthInBytes
);
final
ByteData
result
=
_buffer
!.
buffer
.
asByteData
(
0
,
_buffer
!
.
lengthInBytes
);
_buffer
=
null
;
_buffer
=
null
;
return
result
;
return
result
;
}
}
...
@@ -124,35 +122,35 @@ class ReadBuffer {
...
@@ -124,35 +122,35 @@ class ReadBuffer {
}
}
/// Reads a Uint16 from the buffer.
/// Reads a Uint16 from the buffer.
int
getUint16
({
Endian
endian
})
{
int
getUint16
({
Endian
?
endian
})
{
final
int
value
=
data
.
getUint16
(
_position
,
endian
??
Endian
.
host
);
final
int
value
=
data
.
getUint16
(
_position
,
endian
??
Endian
.
host
);
_position
+=
2
;
_position
+=
2
;
return
value
;
return
value
;
}
}
/// Reads a Uint32 from the buffer.
/// Reads a Uint32 from the buffer.
int
getUint32
({
Endian
endian
})
{
int
getUint32
({
Endian
?
endian
})
{
final
int
value
=
data
.
getUint32
(
_position
,
endian
??
Endian
.
host
);
final
int
value
=
data
.
getUint32
(
_position
,
endian
??
Endian
.
host
);
_position
+=
4
;
_position
+=
4
;
return
value
;
return
value
;
}
}
/// Reads an Int32 from the buffer.
/// Reads an Int32 from the buffer.
int
getInt32
({
Endian
endian
})
{
int
getInt32
({
Endian
?
endian
})
{
final
int
value
=
data
.
getInt32
(
_position
,
endian
??
Endian
.
host
);
final
int
value
=
data
.
getInt32
(
_position
,
endian
??
Endian
.
host
);
_position
+=
4
;
_position
+=
4
;
return
value
;
return
value
;
}
}
/// Reads an Int64 from the buffer.
/// Reads an Int64 from the buffer.
int
getInt64
({
Endian
endian
})
{
int
getInt64
({
Endian
?
endian
})
{
final
int
value
=
data
.
getInt64
(
_position
,
endian
??
Endian
.
host
);
final
int
value
=
data
.
getInt64
(
_position
,
endian
??
Endian
.
host
);
_position
+=
8
;
_position
+=
8
;
return
value
;
return
value
;
}
}
/// Reads a Float64 from the buffer.
/// Reads a Float64 from the buffer.
double
getFloat64
({
Endian
endian
})
{
double
getFloat64
({
Endian
?
endian
})
{
_alignTo
(
8
);
_alignTo
(
8
);
final
double
value
=
data
.
getFloat64
(
_position
,
endian
??
Endian
.
host
);
final
double
value
=
data
.
getFloat64
(
_position
,
endian
??
Endian
.
host
);
_position
+=
8
;
_position
+=
8
;
...
...
packages/flutter/lib/src/foundation/stack_frame.dart
View file @
978a2e7b
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:ui'
show
hashValues
;
import
'dart:ui'
show
hashValues
;
import
'package:meta/meta.dart'
;
import
'package:meta/meta.dart'
;
...
@@ -29,16 +27,16 @@ class StackFrame {
...
@@ -29,16 +27,16 @@ class StackFrame {
/// All parameters must not be null. The [className] may be the empty string
/// All parameters must not be null. The [className] may be the empty string
/// if there is no class (e.g. for a top level library method).
/// if there is no class (e.g. for a top level library method).
const
StackFrame
({
const
StackFrame
({
@
required
this
.
number
,
required
this
.
number
,
@
required
this
.
column
,
required
this
.
column
,
@
required
this
.
line
,
required
this
.
line
,
@
required
this
.
packageScheme
,
required
this
.
packageScheme
,
@
required
this
.
package
,
required
this
.
package
,
@
required
this
.
packagePath
,
required
this
.
packagePath
,
this
.
className
=
''
,
this
.
className
=
''
,
@
required
this
.
method
,
required
this
.
method
,
this
.
isConstructor
=
false
,
this
.
isConstructor
=
false
,
@
required
this
.
source
,
required
this
.
source
,
})
:
assert
(
number
!=
null
),
})
:
assert
(
number
!=
null
),
assert
(
column
!=
null
),
assert
(
column
!=
null
),
assert
(
line
!=
null
),
assert
(
line
!=
null
),
...
@@ -92,11 +90,11 @@ class StackFrame {
...
@@ -92,11 +90,11 @@ class StackFrame {
// On the Web in non-debug builds the stack trace includes the exception
// On the Web in non-debug builds the stack trace includes the exception
// message that precedes the stack trace itself. fromStackTraceLine will
// message that precedes the stack trace itself. fromStackTraceLine will
// return null in that case. We will skip it here.
// return null in that case. We will skip it here.
.
skipWhile
((
StackFrame
frame
)
=>
frame
==
null
)
.
whereType
<
StackFrame
>(
)
.
toList
();
.
toList
();
}
}
static
StackFrame
_parseWebFrame
(
String
line
)
{
static
StackFrame
?
_parseWebFrame
(
String
line
)
{
if
(
kDebugMode
)
{
if
(
kDebugMode
)
{
return
_parseWebDebugFrame
(
line
);
return
_parseWebDebugFrame
(
line
);
}
else
{
}
else
{
...
@@ -111,15 +109,16 @@ class StackFrame {
...
@@ -111,15 +109,16 @@ class StackFrame {
final
RegExp
parser
=
hasPackage
final
RegExp
parser
=
hasPackage
?
RegExp
(
r'^(package.+) (\d+):(\d+)\s+(.+)$'
)
?
RegExp
(
r'^(package.+) (\d+):(\d+)\s+(.+)$'
)
:
RegExp
(
r'^(.+) (\d+):(\d+)\s+(.+)$'
);
:
RegExp
(
r'^(.+) (\d+):(\d+)\s+(.+)$'
);
final
Match
match
=
parser
.
firstMatch
(
line
);
Match
?
match
=
parser
.
firstMatch
(
line
);
assert
(
match
!=
null
,
'Expected
$line
to match
$parser
.'
);
assert
(
match
!=
null
,
'Expected
$line
to match
$parser
.'
);
match
=
match
!;
String
package
=
'<unknown>'
;
String
package
=
'<unknown>'
;
String
packageScheme
=
'<unknown>'
;
String
packageScheme
=
'<unknown>'
;
String
packagePath
=
'<unknown>'
;
String
packagePath
=
'<unknown>'
;
if
(
hasPackage
)
{
if
(
hasPackage
)
{
packageScheme
=
'package'
;
packageScheme
=
'package'
;
final
Uri
packageUri
=
Uri
.
parse
(
match
.
group
(
1
));
final
Uri
packageUri
=
Uri
.
parse
(
match
.
group
(
1
)
!
);
package
=
packageUri
.
pathSegments
[
0
];
package
=
packageUri
.
pathSegments
[
0
];
packagePath
=
packageUri
.
path
.
replaceFirst
(
packageUri
.
pathSegments
[
0
]
+
'/'
,
''
);
packagePath
=
packageUri
.
path
.
replaceFirst
(
packageUri
.
pathSegments
[
0
]
+
'/'
,
''
);
}
}
...
@@ -129,10 +128,10 @@ class StackFrame {
...
@@ -129,10 +128,10 @@ class StackFrame {
packageScheme:
packageScheme
,
packageScheme:
packageScheme
,
package:
package
,
package:
package
,
packagePath:
packagePath
,
packagePath:
packagePath
,
line:
int
.
parse
(
match
.
group
(
2
)),
line:
int
.
parse
(
match
.
group
(
2
)
!
),
column:
int
.
parse
(
match
.
group
(
3
)),
column:
int
.
parse
(
match
.
group
(
3
)
!
),
className:
'<unknown>'
,
className:
'<unknown>'
,
method:
match
.
group
(
4
),
method:
match
.
group
(
4
)
!
,
source
:
line
,
source
:
line
,
);
);
}
}
...
@@ -145,8 +144,8 @@ class StackFrame {
...
@@ -145,8 +144,8 @@ class StackFrame {
// Parses `line` as a stack frame in profile and release Web builds. If not
// Parses `line` as a stack frame in profile and release Web builds. If not
// recognized as a stack frame, returns null.
// recognized as a stack frame, returns null.
static
StackFrame
_parseWebNonDebugFrame
(
String
line
)
{
static
StackFrame
?
_parseWebNonDebugFrame
(
String
line
)
{
final
Match
match
=
_webNonDebugFramePattern
.
firstMatch
(
line
);
final
Match
?
match
=
_webNonDebugFramePattern
.
firstMatch
(
line
);
if
(
match
==
null
)
{
if
(
match
==
null
)
{
// On the Web in non-debug builds the stack trace includes the exception
// On the Web in non-debug builds the stack trace includes the exception
// message that precedes the stack trace itself. Example:
// message that precedes the stack trace itself. Example:
...
@@ -162,7 +161,7 @@ class StackFrame {
...
@@ -162,7 +161,7 @@ class StackFrame {
return
null
;
return
null
;
}
}
final
List
<
String
>
classAndMethod
=
match
.
group
(
1
).
split
(
'.'
);
final
List
<
String
>
classAndMethod
=
match
.
group
(
1
)
!
.
split
(
'.'
);
final
String
className
=
classAndMethod
.
length
>
1
?
classAndMethod
.
first
:
'<unknown>'
;
final
String
className
=
classAndMethod
.
length
>
1
?
classAndMethod
.
first
:
'<unknown>'
;
final
String
method
=
classAndMethod
.
length
>
1
final
String
method
=
classAndMethod
.
length
>
1
?
classAndMethod
.
skip
(
1
).
join
(
'.'
)
?
classAndMethod
.
skip
(
1
).
join
(
'.'
)
...
@@ -182,7 +181,7 @@ class StackFrame {
...
@@ -182,7 +181,7 @@ class StackFrame {
}
}
/// Parses a single [StackFrame] from a single line of a [StackTrace].
/// Parses a single [StackFrame] from a single line of a [StackTrace].
static
StackFrame
fromStackTraceLine
(
String
line
)
{
static
StackFrame
?
fromStackTraceLine
(
String
line
)
{
assert
(
line
!=
null
);
assert
(
line
!=
null
);
if
(
line
==
'<asynchronous suspension>'
)
{
if
(
line
==
'<asynchronous suspension>'
)
{
return
asynchronousSuspension
;
return
asynchronousSuspension
;
...
@@ -203,12 +202,13 @@ class StackFrame {
...
@@ -203,12 +202,13 @@ class StackFrame {
}
}
final
RegExp
parser
=
RegExp
(
r'^#(\d+) +(.+) \((.+?):?(\d+){0,1}:?(\d+){0,1}\)$'
);
final
RegExp
parser
=
RegExp
(
r'^#(\d+) +(.+) \((.+?):?(\d+){0,1}:?(\d+){0,1}\)$'
);
final
Match
match
=
parser
.
firstMatch
(
line
);
Match
?
match
=
parser
.
firstMatch
(
line
);
assert
(
match
!=
null
,
'Expected
$line
to match
$parser
.'
);
assert
(
match
!=
null
,
'Expected
$line
to match
$parser
.'
);
match
=
match
!;
bool
isConstructor
=
false
;
bool
isConstructor
=
false
;
String
className
=
''
;
String
className
=
''
;
String
method
=
match
.
group
(
2
).
replaceAll
(
'.<anonymous closure>'
,
''
);
String
method
=
match
.
group
(
2
)
!
.
replaceAll
(
'.<anonymous closure>'
,
''
);
if
(
method
.
startsWith
(
'new'
))
{
if
(
method
.
startsWith
(
'new'
))
{
className
=
method
.
split
(
' '
)[
1
];
className
=
method
.
split
(
' '
)[
1
];
method
=
''
;
method
=
''
;
...
@@ -224,7 +224,7 @@ class StackFrame {
...
@@ -224,7 +224,7 @@ class StackFrame {
method
=
parts
[
1
];
method
=
parts
[
1
];
}
}
final
Uri
packageUri
=
Uri
.
parse
(
match
.
group
(
3
));
final
Uri
packageUri
=
Uri
.
parse
(
match
.
group
(
3
)
!
);
String
package
=
'<unknown>'
;
String
package
=
'<unknown>'
;
String
packagePath
=
packageUri
.
path
;
String
packagePath
=
packageUri
.
path
;
if
(
packageUri
.
scheme
==
'dart'
||
packageUri
.
scheme
==
'package'
)
{
if
(
packageUri
.
scheme
==
'dart'
||
packageUri
.
scheme
==
'package'
)
{
...
@@ -233,14 +233,14 @@ class StackFrame {
...
@@ -233,14 +233,14 @@ class StackFrame {
}
}
return
StackFrame
(
return
StackFrame
(
number:
int
.
parse
(
match
.
group
(
1
)),
number:
int
.
parse
(
match
.
group
(
1
)
!
),
className:
className
,
className:
className
,
method:
method
,
method:
method
,
packageScheme:
packageUri
.
scheme
,
packageScheme:
packageUri
.
scheme
,
package:
package
,
package:
package
,
packagePath:
packagePath
,
packagePath:
packagePath
,
line:
match
.
group
(
4
)
==
null
?
-
1
:
int
.
parse
(
match
.
group
(
4
)),
line:
match
.
group
(
4
)
==
null
?
-
1
:
int
.
parse
(
match
.
group
(
4
)
!
),
column:
match
.
group
(
5
)
==
null
?
-
1
:
int
.
parse
(
match
.
group
(
5
)),
column:
match
.
group
(
5
)
==
null
?
-
1
:
int
.
parse
(
match
.
group
(
5
)
!
),
isConstructor:
isConstructor
,
isConstructor:
isConstructor
,
source
:
line
,
source
:
line
,
);
);
...
...
packages/flutter/lib/src/foundation/synchronous_future.dart
View file @
978a2e7b
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'dart:async'
;
import
'dart:async'
;
/// A [Future] whose [then] implementation calls the callback immediately.
/// A [Future] whose [then] implementation calls the callback immediately.
...
@@ -36,18 +34,18 @@ class SynchronousFuture<T> implements Future<T> {
...
@@ -36,18 +34,18 @@ class SynchronousFuture<T> implements Future<T> {
}
}
@override
@override
Future
<
T
>
catchError
(
Function
onError
,
{
bool
test
(
Object
error
)
})
=>
Completer
<
T
>().
future
;
Future
<
T
>
catchError
(
Function
onError
,
{
bool
test
(
Object
error
)
?
})
=>
Completer
<
T
>().
future
;
@override
@override
Future
<
E
>
then
<
E
>(
FutureOr
<
E
>
f
(
T
value
),
{
Function
onError
})
{
Future
<
R
>
then
<
R
>(
FutureOr
<
R
>
onValue
(
T
value
),
{
Function
?
onError
})
{
final
dynamic
result
=
f
(
_value
);
final
dynamic
result
=
onValue
(
_value
);
if
(
result
is
Future
<
E
>)
if
(
result
is
Future
<
R
>)
return
result
;
return
result
;
return
SynchronousFuture
<
E
>(
result
as
E
);
return
SynchronousFuture
<
R
>(
result
as
R
);
}
}
@override
@override
Future
<
T
>
timeout
(
Duration
timeLimit
,
{
FutureOr
<
T
>
onTimeout
()
})
{
Future
<
T
>
timeout
(
Duration
timeLimit
,
{
FutureOr
<
T
>
onTimeout
()
?
})
{
return
Future
<
T
>.
value
(
_value
).
timeout
(
timeLimit
,
onTimeout:
onTimeout
);
return
Future
<
T
>.
value
(
_value
).
timeout
(
timeLimit
,
onTimeout:
onTimeout
);
}
}
...
...
packages/flutter/lib/src/foundation/unicode.dart
View file @
978a2e7b
...
@@ -2,8 +2,6 @@
...
@@ -2,8 +2,6 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
/// Constants for useful Unicode characters.
/// Constants for useful Unicode characters.
///
///
/// Currently, these characters are all related to bidirectional text.
/// Currently, these characters are all related to bidirectional text.
...
...
packages/flutter/test/widgets/texture_test.dart
View file @
978a2e7b
...
@@ -2,6 +2,8 @@
...
@@ -2,6 +2,8 @@
// Use of this source code is governed by a BSD-style license that can be
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// found in the LICENSE file.
// @dart = 2.8
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/rendering.dart'
;
import
'package:flutter/widgets.dart'
;
import
'package:flutter/widgets.dart'
;
...
...
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