migrate foundation to nullsafety (#61188)
* migrate foundation to nullsafety * address review comments
This commit is contained in:
parent
cb7770b3a5
commit
978a2e7bf6
@ -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
|
||||||
|
@ -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
|
||||||
|
@ -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].
|
||||||
|
@ -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].
|
||||||
|
@ -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';
|
|||||||
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);
|
||||||
|
@ -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.
|
||||||
|
@ -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 {
|
|||||||
'Consider updating the list of TargetPlatforms to include this platform.'
|
'Consider updating the list of TargetPlatforms to include this platform.'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
return result;
|
return result!;
|
||||||
}
|
}
|
||||||
|
@ -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 {
|
|||||||
// 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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 { }
|
||||||
|
|
||||||
|
@ -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 {
|
|||||||
/// 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 {
|
|||||||
/// `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 {
|
|||||||
/// 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 {
|
|||||||
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>> {
|
|||||||
level: level,
|
level: level,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
|
||||||
@override
|
@override
|
||||||
String valueToString({ TextTreeConfiguration parentConfiguration }) {
|
List<Object> get value => super.value!;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String valueToString({ TextTreeConfiguration? parentConfiguration }) {
|
||||||
return value.join('');
|
return value.join('');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -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 {
|
|||||||
/// 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 {
|
|||||||
/// 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 {
|
|||||||
/// 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 {
|
|||||||
///
|
///
|
||||||
/// 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 {
|
|||||||
/// 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 {
|
|||||||
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 {
|
|||||||
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 {
|
|||||||
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 {
|
|||||||
// 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 {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
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 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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
|
|||||||
///
|
///
|
||||||
/// 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
|
|||||||
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
|
|||||||
|
|
||||||
@override
|
@override
|
||||||
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
|
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
|
||||||
diagnostics?.forEach(properties.add);
|
diagnostics.forEach(properties.add);
|
||||||
}
|
}
|
||||||
|
|
||||||
@override
|
@override
|
||||||
@ -1079,12 +1078,11 @@ 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
|
|||||||
/// 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 {
|
|||||||
/// [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 {
|
|||||||
/// 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 {
|
|||||||
);
|
);
|
||||||
|
|
||||||
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 {
|
|||||||
|
|
||||||
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> {
|
|||||||
);
|
);
|
||||||
|
|
||||||
@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;
|
||||||
}
|
}
|
||||||
|
@ -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> {
|
|||||||
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];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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 {
|
|||||||
/// {@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 {
|
|||||||
/// {@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 {
|
|||||||
/// {@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 {
|
|||||||
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 {
|
|||||||
/// {@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 {
|
|||||||
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 {
|
|||||||
/// {@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 {
|
|||||||
});
|
});
|
||||||
|
|
||||||
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) {
|
||||||
|
@ -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;
|
||||||
|
|
||||||
|
@ -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 {
|
|||||||
/// 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 {
|
|||||||
///
|
///
|
||||||
/// * [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 {
|
|||||||
@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 {
|
|||||||
@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 {
|
|||||||
@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 {
|
|||||||
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 {
|
|||||||
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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 @@
|
|||||||
///
|
///
|
||||||
/// * [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) {
|
|||||||
///
|
///
|
||||||
/// * [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) {
|
|||||||
///
|
///
|
||||||
/// * [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;
|
|||||||
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>(
|
|||||||
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>(
|
|||||||
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>() {
|
|||||||
/// 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>(
|
|||||||
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>(
|
|||||||
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>(
|
|||||||
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>(
|
|||||||
// 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>(
|
|||||||
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>(
|
|||||||
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>(
|
|||||||
} 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.
|
||||||
|
@ -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';
|
|||||||
/// 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);
|
|||||||
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(
|
|||||||
}
|
}
|
||||||
|
|
||||||
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(
|
|||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
|||||||
}
|
}
|
||||||
_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 {
|
|||||||
|
|
||||||
Uint8List get bytes {
|
Uint8List get bytes {
|
||||||
assert(_bytes != null);
|
assert(_bytes != null);
|
||||||
return _bytes;
|
return _bytes!;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
@ -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;
|
|||||||
/// * [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()) {
|
|||||||
}());
|
}());
|
||||||
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
|
|||||||
/// 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) {
|
|||||||
///
|
///
|
||||||
/// * [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;
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -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'
|
|||||||
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`.
|
||||||
|
@ -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';
|
||||||
|
@ -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 {
|
|||||||
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 {
|
|||||||
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 {
|
|||||||
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 {
|
|||||||
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 {
|
|||||||
// 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 {
|
|||||||
/// 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 {
|
|||||||
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();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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 {
|
|||||||
/// 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 {
|
|||||||
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 {
|
|||||||
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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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 @@
|
|||||||
/// 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;
|
||||||
|
@ -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';
|
|||||||
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> {
|
|||||||
/// 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.addAll(_list);
|
||||||
_set = HashSet<T>.from(_list);
|
|
||||||
} else {
|
|
||||||
_set.addAll(_list);
|
|
||||||
}
|
|
||||||
_isDirty = false;
|
_isDirty = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -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> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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;
|
||||||
|
@ -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 {
|
|||||||
/// 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;
|
||||||
|
@ -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;
|
|||||||
|
|
||||||
/// 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 }) {
|
|||||||
|
|
||||||
/// 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;
|
|||||||
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 =
|
|||||||
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
|
||||||
|
@ -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;
|
|||||||
/// 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 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// 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;
|
||||||
|
@ -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 {
|
|||||||
/// 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 {
|
|||||||
// 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 {
|
|||||||
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 {
|
|||||||
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 {
|
|||||||
|
|
||||||
// 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 {
|
|||||||
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 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/// 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 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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 {
|
|||||||
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 {
|
|||||||
}
|
}
|
||||||
|
|
||||||
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,
|
||||||
);
|
);
|
||||||
|
@ -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> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@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);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -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.
|
||||||
|
@ -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';
|
||||||
|
Loading…
x
Reference in New Issue
Block a user