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:
|
||||
enable-experiment:
|
||||
- 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
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
/// Core Flutter framework primitives.
|
||||
///
|
||||
/// 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
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'bitfield.dart' as bitfield;
|
||||
|
||||
/// 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
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'bitfield.dart' as bitfield;
|
||||
|
||||
/// 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
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:developer';
|
||||
import 'dart:isolate';
|
||||
@ -13,7 +11,7 @@ import 'constants.dart';
|
||||
import 'isolates.dart' as isolates;
|
||||
|
||||
/// 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();
|
||||
final Flow flow = Flow.begin();
|
||||
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
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'isolates.dart' as isolates;
|
||||
|
||||
/// 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
|
||||
// pump a single frame to allow the framework to complete the current set
|
||||
// of work.
|
||||
|
@ -2,15 +2,13 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:io';
|
||||
import 'assertions.dart';
|
||||
import 'platform.dart' as platform;
|
||||
|
||||
/// The dart:io implementation of [platform.defaultTargetPlatform].
|
||||
platform.TargetPlatform get defaultTargetPlatform {
|
||||
platform.TargetPlatform result;
|
||||
platform.TargetPlatform? result;
|
||||
if (Platform.isAndroid) {
|
||||
result = platform.TargetPlatform.android;
|
||||
} else if (Platform.isIOS) {
|
||||
@ -38,5 +36,5 @@ platform.TargetPlatform get defaultTargetPlatform {
|
||||
'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
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:html' as html;
|
||||
import 'platform.dart' as platform;
|
||||
|
||||
@ -14,7 +12,7 @@ platform.TargetPlatform get defaultTargetPlatform {
|
||||
// platforms configuration for Flutter.
|
||||
platform.TargetPlatform result = _browserPlatform();
|
||||
if (platform.debugDefaultTargetPlatformOverride != null)
|
||||
result = platform.debugDefaultTargetPlatformOverride;
|
||||
result = platform.debugDefaultTargetPlatformOverride!;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
// Examples can assume:
|
||||
// class Cat { }
|
||||
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
import 'basic_types.dart';
|
||||
@ -46,9 +44,9 @@ class PartialStackFrame {
|
||||
/// Creates a new [PartialStackFrame] instance. All arguments are required and
|
||||
/// must not be null.
|
||||
const PartialStackFrame({
|
||||
@required this.package,
|
||||
@required this.className,
|
||||
@required this.method,
|
||||
required this.package,
|
||||
required this.className,
|
||||
required this.method,
|
||||
}) : assert(className != null),
|
||||
assert(method != null),
|
||||
assert(package != null);
|
||||
@ -102,7 +100,7 @@ abstract class StackFilter {
|
||||
/// `reasons`.
|
||||
///
|
||||
/// 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
|
||||
/// null.
|
||||
const RepetitiveStackFrameFilter({
|
||||
@required this.frames,
|
||||
@required this.replacement,
|
||||
required this.frames,
|
||||
required this.replacement,
|
||||
}) : assert(frames != null),
|
||||
assert(replacement != null);
|
||||
|
||||
@ -141,7 +139,7 @@ class RepetitiveStackFrameFilter extends StackFilter {
|
||||
List<String> get _replacements => List<String>.filled(numFrames, replacement);
|
||||
|
||||
@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) {
|
||||
if (_matchesFrames(stackFrames.skip(index).take(numFrames).toList())) {
|
||||
reasons.setRange(index, index + numFrames, _replacements);
|
||||
@ -222,8 +220,12 @@ abstract class _ErrorDiagnostic extends DiagnosticsProperty<List<Object>> {
|
||||
level: level,
|
||||
);
|
||||
|
||||
|
||||
@override
|
||||
String valueToString({ TextTreeConfiguration parentConfiguration }) {
|
||||
List<Object> get value => super.value!;
|
||||
|
||||
@override
|
||||
String valueToString({ TextTreeConfiguration? parentConfiguration }) {
|
||||
return value.join('');
|
||||
}
|
||||
}
|
||||
@ -400,13 +402,13 @@ class FlutterErrorDetails with Diagnosticable {
|
||||
/// Creates a copy of the error details but with the given fields replaced
|
||||
/// with new values.
|
||||
FlutterErrorDetails copyWith({
|
||||
DiagnosticsNode context,
|
||||
DiagnosticsNode? context,
|
||||
dynamic exception,
|
||||
InformationCollector informationCollector,
|
||||
String library,
|
||||
bool silent,
|
||||
StackTrace stack,
|
||||
IterableFilter<String> stackFilter,
|
||||
InformationCollector? informationCollector,
|
||||
String? library,
|
||||
bool? silent,
|
||||
StackTrace? stack,
|
||||
IterableFilter<String>? stackFilter,
|
||||
}) {
|
||||
return FlutterErrorDetails(
|
||||
context: context ?? this.context,
|
||||
@ -448,12 +450,12 @@ class FlutterErrorDetails with Diagnosticable {
|
||||
/// callback, then [FlutterError.defaultStackFilter] is used instead. That
|
||||
/// function expects the stack to be in the format used by
|
||||
/// [StackTrace.toString].
|
||||
final StackTrace stack;
|
||||
final StackTrace? stack;
|
||||
|
||||
/// 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
|
||||
/// the console.
|
||||
final String library;
|
||||
final String? library;
|
||||
|
||||
/// A [DiagnosticsNode] that provides a human-readable description of where
|
||||
/// the error was caught (as opposed to where it was thrown).
|
||||
@ -494,7 +496,7 @@ class FlutterErrorDetails with Diagnosticable {
|
||||
/// applicable.
|
||||
/// * [FlutterError], which is the most common place to use
|
||||
/// [FlutterErrorDetails].
|
||||
final DiagnosticsNode context;
|
||||
final DiagnosticsNode? context;
|
||||
|
||||
/// A callback which filters the [stack] trace. Receives an iterable of
|
||||
/// 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.
|
||||
///
|
||||
/// 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
|
||||
/// 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
|
||||
/// not end with a newline.
|
||||
final InformationCollector informationCollector;
|
||||
final InformationCollector? informationCollector;
|
||||
|
||||
/// Whether this error should be ignored by the default error reporting
|
||||
/// behavior in release mode.
|
||||
@ -544,13 +546,13 @@ class FlutterErrorDetails with Diagnosticable {
|
||||
/// prettier, to handle exceptions that stringify to empty strings, to handle
|
||||
/// objects that don't inherit from [Exception] or [Error], and so forth.
|
||||
String exceptionAsString() {
|
||||
String longMessage;
|
||||
String? longMessage;
|
||||
if (exception is AssertionError) {
|
||||
// Regular _AssertionErrors thrown by assert() put the message last, after
|
||||
// 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
|
||||
// newline, if we recognize that format is being used.
|
||||
final Object message = exception.message;
|
||||
final Object? message = exception.message;
|
||||
final String fullMessage = exception.toString();
|
||||
if (message is String && message != fullMessage) {
|
||||
if (fullMessage.length > message.length) {
|
||||
@ -583,7 +585,7 @@ class FlutterErrorDetails with Diagnosticable {
|
||||
return longMessage;
|
||||
}
|
||||
|
||||
Diagnosticable _exceptionToDiagnosticable() {
|
||||
Diagnosticable? _exceptionToDiagnosticable() {
|
||||
if (exception is FlutterError) {
|
||||
return exception as FlutterError;
|
||||
}
|
||||
@ -606,12 +608,12 @@ class FlutterErrorDetails with Diagnosticable {
|
||||
if (kReleaseMode) {
|
||||
return DiagnosticsNode.message(formatException());
|
||||
}
|
||||
final Diagnosticable diagnosticable = _exceptionToDiagnosticable();
|
||||
DiagnosticsNode summary;
|
||||
final Diagnosticable? diagnosticable = _exceptionToDiagnosticable();
|
||||
DiagnosticsNode? summary;
|
||||
if (diagnosticable != null) {
|
||||
final DiagnosticPropertiesBuilder builder = DiagnosticPropertiesBuilder();
|
||||
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());
|
||||
}
|
||||
@ -620,7 +622,7 @@ class FlutterErrorDetails with Diagnosticable {
|
||||
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
|
||||
super.debugFillProperties(properties);
|
||||
final DiagnosticsNode verb = ErrorDescription('thrown${ context != null ? ErrorDescription(" $context") : ""}');
|
||||
final Diagnosticable diagnosticable = _exceptionToDiagnosticable();
|
||||
final Diagnosticable? diagnosticable = _exceptionToDiagnosticable();
|
||||
if (exception is NullThrownError) {
|
||||
properties.add(ErrorDescription('The null value was $verb.'));
|
||||
} 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 so: Error is in Framework. We either need an assertion higher up
|
||||
// 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')
|
||||
.toList();
|
||||
final bool ourFault = stackFrames.length >= 2
|
||||
@ -677,11 +679,11 @@ class FlutterErrorDetails with Diagnosticable {
|
||||
}
|
||||
}
|
||||
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) {
|
||||
properties.add(ErrorSpacer());
|
||||
informationCollector().forEach(properties.add);
|
||||
informationCollector!().forEach(properties.add);
|
||||
}
|
||||
}
|
||||
|
||||
@ -696,7 +698,7 @@ class FlutterErrorDetails with Diagnosticable {
|
||||
}
|
||||
|
||||
@override
|
||||
DiagnosticsNode toDiagnosticsNode({ String name, DiagnosticsTreeStyle style }) {
|
||||
DiagnosticsNode toDiagnosticsNode({ String? name, DiagnosticsTreeStyle? style }) {
|
||||
return _FlutterErrorDetailsNode(
|
||||
name: name,
|
||||
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
|
||||
/// Flutter framework.
|
||||
///
|
||||
/// Set this to null to silently catch and ignore errors. This is not
|
||||
/// recommended.
|
||||
static FlutterExceptionHandler onError = (FlutterErrorDetails details) => presentError(details);
|
||||
|
||||
/// 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}';
|
||||
if (removedPackagesAndClasses.containsKey(className)) {
|
||||
skipped += 1;
|
||||
removedPackagesAndClasses[className] += 1;
|
||||
removedPackagesAndClasses.update(className, (int value) => value + 1);
|
||||
parsedFrames.removeAt(index);
|
||||
index -= 1;
|
||||
} else if (removedPackagesAndClasses.containsKey(package)) {
|
||||
skipped += 1;
|
||||
removedPackagesAndClasses[package] += 1;
|
||||
removedPackagesAndClasses.update(package, (int value) => value + 1);
|
||||
parsedFrames.removeAt(index);
|
||||
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) {
|
||||
filter.filter(parsedFrames, reasons);
|
||||
}
|
||||
@ -1062,7 +1061,7 @@ class FlutterError extends Error with DiagnosticableTreeMixin implements Asserti
|
||||
|
||||
@override
|
||||
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
|
||||
diagnostics?.forEach(properties.add);
|
||||
diagnostics.forEach(properties.add);
|
||||
}
|
||||
|
||||
@override
|
||||
@ -1079,12 +1078,11 @@ class FlutterError extends Error with DiagnosticableTreeMixin implements Asserti
|
||||
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) {
|
||||
assert(details != 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.
|
||||
///
|
||||
/// 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)
|
||||
debugPrint(label);
|
||||
if (stackTrace == null) {
|
||||
@ -1136,8 +1134,8 @@ class DiagnosticsStackTrace extends DiagnosticsBlock {
|
||||
/// [showSeparator] indicates whether to include a ':' after the [name].
|
||||
DiagnosticsStackTrace(
|
||||
String name,
|
||||
StackTrace stack, {
|
||||
IterableFilter<String> stackFilter,
|
||||
StackTrace? stack, {
|
||||
IterableFilter<String>? stackFilter,
|
||||
bool showSeparator = true,
|
||||
}) : super(
|
||||
name: name,
|
||||
@ -1151,7 +1149,7 @@ class DiagnosticsStackTrace extends DiagnosticsBlock {
|
||||
/// Creates a diagnostic describing a single frame from a StackTrace.
|
||||
DiagnosticsStackTrace.singleFrame(
|
||||
String name, {
|
||||
@required String frame,
|
||||
required String frame,
|
||||
bool showSeparator = true,
|
||||
}) : super(
|
||||
name: name,
|
||||
@ -1161,8 +1159,8 @@ class DiagnosticsStackTrace extends DiagnosticsBlock {
|
||||
);
|
||||
|
||||
static List<DiagnosticsNode> _applyStackFilter(
|
||||
StackTrace stack,
|
||||
IterableFilter<String> stackFilter,
|
||||
StackTrace? stack,
|
||||
IterableFilter<String>? stackFilter,
|
||||
) {
|
||||
if (stack == null)
|
||||
return <DiagnosticsNode>[];
|
||||
@ -1178,9 +1176,9 @@ class DiagnosticsStackTrace extends DiagnosticsBlock {
|
||||
|
||||
class _FlutterErrorDetailsNode extends DiagnosticableNode<FlutterErrorDetails> {
|
||||
_FlutterErrorDetailsNode({
|
||||
String name,
|
||||
@required FlutterErrorDetails value,
|
||||
@required DiagnosticsTreeStyle style,
|
||||
String? name,
|
||||
required FlutterErrorDetails value,
|
||||
required DiagnosticsTreeStyle? style,
|
||||
}) : super(
|
||||
name: name,
|
||||
value: value,
|
||||
@ -1188,8 +1186,8 @@ class _FlutterErrorDetailsNode extends DiagnosticableNode<FlutterErrorDetails> {
|
||||
);
|
||||
|
||||
@override
|
||||
DiagnosticPropertiesBuilder get builder {
|
||||
final DiagnosticPropertiesBuilder builder = super.builder;
|
||||
DiagnosticPropertiesBuilder? get builder {
|
||||
final DiagnosticPropertiesBuilder? builder = super.builder;
|
||||
if (builder == null){
|
||||
return null;
|
||||
}
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:collection';
|
||||
|
||||
@ -207,7 +205,7 @@ class _LazyListIterator<E> implements Iterator<E> {
|
||||
E get current {
|
||||
assert(_index >= 0); // called "current" before "moveNext()"
|
||||
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];
|
||||
}
|
||||
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert' show json;
|
||||
import 'dart:developer' as developer;
|
||||
@ -316,8 +314,8 @@ abstract class BindingBase {
|
||||
/// {@macro flutter.foundation.bindingBase.registerServiceExtension}
|
||||
@protected
|
||||
void registerSignalServiceExtension({
|
||||
@required String name,
|
||||
@required AsyncCallback callback,
|
||||
required String name,
|
||||
required AsyncCallback callback,
|
||||
}) {
|
||||
assert(name != null);
|
||||
assert(callback != null);
|
||||
@ -346,9 +344,9 @@ abstract class BindingBase {
|
||||
/// {@macro flutter.foundation.bindingBase.registerServiceExtension}
|
||||
@protected
|
||||
void registerBoolServiceExtension({
|
||||
@required String name,
|
||||
@required AsyncValueGetter<bool> getter,
|
||||
@required AsyncValueSetter<bool> setter,
|
||||
required String name,
|
||||
required AsyncValueGetter<bool> getter,
|
||||
required AsyncValueSetter<bool> setter,
|
||||
}) {
|
||||
assert(name != null);
|
||||
assert(getter != null);
|
||||
@ -380,9 +378,9 @@ abstract class BindingBase {
|
||||
/// {@macro flutter.foundation.bindingBase.registerServiceExtension}
|
||||
@protected
|
||||
void registerNumericServiceExtension({
|
||||
@required String name,
|
||||
@required AsyncValueGetter<double> getter,
|
||||
@required AsyncValueSetter<double> setter,
|
||||
required String name,
|
||||
required AsyncValueGetter<double> getter,
|
||||
required AsyncValueSetter<double> setter,
|
||||
}) {
|
||||
assert(name != null);
|
||||
assert(getter != null);
|
||||
@ -391,7 +389,7 @@ abstract class BindingBase {
|
||||
name: name,
|
||||
callback: (Map<String, String> parameters) async {
|
||||
if (parameters.containsKey(name)) {
|
||||
await setter(double.parse(parameters[name]));
|
||||
await setter(double.parse(parameters[name]!));
|
||||
_postExtensionStateChangedEvent(name, (await getter()).toString());
|
||||
}
|
||||
return <String, dynamic>{name: (await getter()).toString()};
|
||||
@ -442,9 +440,9 @@ abstract class BindingBase {
|
||||
/// {@macro flutter.foundation.bindingBase.registerServiceExtension}
|
||||
@protected
|
||||
void registerStringServiceExtension({
|
||||
@required String name,
|
||||
@required AsyncValueGetter<String> getter,
|
||||
@required AsyncValueSetter<String> setter,
|
||||
required String name,
|
||||
required AsyncValueGetter<String> getter,
|
||||
required AsyncValueSetter<String> setter,
|
||||
}) {
|
||||
assert(name != null);
|
||||
assert(getter != null);
|
||||
@ -453,7 +451,7 @@ abstract class BindingBase {
|
||||
name: name,
|
||||
callback: (Map<String, String> parameters) async {
|
||||
if (parameters.containsKey('value')) {
|
||||
await setter(parameters['value']);
|
||||
await setter(parameters['value']!);
|
||||
_postExtensionStateChangedEvent(name, await getter());
|
||||
}
|
||||
return <String, dynamic>{'value': await getter()};
|
||||
@ -514,8 +512,8 @@ abstract class BindingBase {
|
||||
/// {@endtemplate}
|
||||
@protected
|
||||
void registerServiceExtension({
|
||||
@required String name,
|
||||
@required ServiceExtensionCallback callback,
|
||||
required String name,
|
||||
required ServiceExtensionCallback callback,
|
||||
}) {
|
||||
assert(name != null);
|
||||
assert(callback != null);
|
||||
@ -543,8 +541,8 @@ abstract class BindingBase {
|
||||
});
|
||||
|
||||
dynamic caughtException;
|
||||
StackTrace caughtStack;
|
||||
Map<String, dynamic> result;
|
||||
StackTrace? caughtStack;
|
||||
late Map<String, dynamic> result;
|
||||
try {
|
||||
result = await callback(parameters);
|
||||
} catch (exception, stack) {
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import '_bitfield_io.dart'
|
||||
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
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
import 'assertions.dart';
|
||||
@ -65,7 +63,7 @@ abstract class Listenable {
|
||||
/// will lead to memory leaks or exceptions.
|
||||
///
|
||||
/// 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.
|
||||
void addListener(VoidCallback listener);
|
||||
@ -100,7 +98,7 @@ abstract class ValueListenable<T> extends Listenable {
|
||||
///
|
||||
/// * [ValueNotifier], which is a [ChangeNotifier] that wraps a single value.
|
||||
class ChangeNotifier implements Listenable {
|
||||
ObserverList<VoidCallback> _listeners = ObserverList<VoidCallback>();
|
||||
ObserverList<VoidCallback>? _listeners = ObserverList<VoidCallback>();
|
||||
|
||||
bool _debugAssertNotDisposed() {
|
||||
assert(() {
|
||||
@ -133,7 +131,7 @@ class ChangeNotifier implements Listenable {
|
||||
@protected
|
||||
bool get hasListeners {
|
||||
assert(_debugAssertNotDisposed());
|
||||
return _listeners.isNotEmpty;
|
||||
return _listeners!.isNotEmpty;
|
||||
}
|
||||
|
||||
/// Register a closure to be called when the object changes.
|
||||
@ -142,7 +140,7 @@ class ChangeNotifier implements Listenable {
|
||||
@override
|
||||
void addListener(VoidCallback listener) {
|
||||
assert(_debugAssertNotDisposed());
|
||||
_listeners.add(listener);
|
||||
_listeners!.add(listener);
|
||||
}
|
||||
|
||||
/// Remove a previously registered closure from the list of closures that are
|
||||
@ -167,7 +165,7 @@ class ChangeNotifier implements Listenable {
|
||||
@override
|
||||
void removeListener(VoidCallback listener) {
|
||||
assert(_debugAssertNotDisposed());
|
||||
_listeners.remove(listener);
|
||||
_listeners!.remove(listener);
|
||||
}
|
||||
|
||||
/// Discards any resources used by the object. After this is called, the
|
||||
@ -202,10 +200,10 @@ class ChangeNotifier implements Listenable {
|
||||
void notifyListeners() {
|
||||
assert(_debugAssertNotDisposed());
|
||||
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) {
|
||||
try {
|
||||
if (_listeners.contains(listener))
|
||||
if (_listeners!.contains(listener))
|
||||
listener();
|
||||
} catch (exception, stack) {
|
||||
FlutterError.reportError(FlutterErrorDetails(
|
||||
@ -230,18 +228,18 @@ class ChangeNotifier implements Listenable {
|
||||
class _MergingListenable extends Listenable {
|
||||
_MergingListenable(this._children);
|
||||
|
||||
final List<Listenable> _children;
|
||||
final List<Listenable?> _children;
|
||||
|
||||
@override
|
||||
void addListener(VoidCallback listener) {
|
||||
for (final Listenable child in _children) {
|
||||
for (final Listenable? child in _children) {
|
||||
child?.addListener(listener);
|
||||
}
|
||||
}
|
||||
|
||||
@override
|
||||
void removeListener(VoidCallback listener) {
|
||||
for (final Listenable child in _children) {
|
||||
for (final Listenable? child in _children) {
|
||||
child?.removeListener(listener);
|
||||
}
|
||||
}
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
// TODO(ianh): These should be on the Set and List classes themselves.
|
||||
|
||||
/// Compares two sets for deep equality.
|
||||
@ -21,7 +19,7 @@
|
||||
///
|
||||
/// * [listEquals], which does something similar for lists.
|
||||
/// * [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)
|
||||
return b == null;
|
||||
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.
|
||||
/// * [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)
|
||||
return b == null;
|
||||
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.
|
||||
/// * [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)
|
||||
return b == null;
|
||||
if (b == null || a.length != b.length)
|
||||
@ -145,8 +143,8 @@ const int _kMergeSortLimit = 32;
|
||||
void mergeSort<T>(
|
||||
List<T> list, {
|
||||
int start = 0,
|
||||
int end,
|
||||
int Function(T, T) compare,
|
||||
int? end,
|
||||
int Function(T, T)? compare,
|
||||
}) {
|
||||
end ??= list.length;
|
||||
compare ??= _defaultCompare<T>();
|
||||
@ -156,7 +154,7 @@ void mergeSort<T>(
|
||||
return;
|
||||
}
|
||||
if (length < _kMergeSortLimit) {
|
||||
_insertionSort(list, compare: compare, start: start, end: end);
|
||||
_insertionSort<T>(list, compare: compare, start: start, end: end);
|
||||
return;
|
||||
}
|
||||
// Special case the first split instead of directly calling _mergeSort,
|
||||
@ -168,11 +166,11 @@ void mergeSort<T>(
|
||||
final int firstLength = middle - start;
|
||||
final int secondLength = end - middle;
|
||||
// secondLength is always the same as firstLength, or one greater.
|
||||
final List<T> scratchSpace = List<T>(secondLength);
|
||||
_mergeSort(list, compare, middle, end, scratchSpace, 0);
|
||||
final List<T?> scratchSpace = List<T?>.filled(secondLength, null, growable: false);
|
||||
_mergeSort<T>(list, compare, middle, end, scratchSpace, 0);
|
||||
final int firstTarget = end - firstLength;
|
||||
_mergeSort(list, compare, start, middle, list, firstTarget);
|
||||
_merge(compare, list, firstTarget, end, scratchSpace, 0, secondLength, list, start);
|
||||
_mergeSort<T>(list, compare, start, middle, list, firstTarget);
|
||||
_merge<T>(compare, list, firstTarget, end, scratchSpace, 0, secondLength, list, start);
|
||||
}
|
||||
|
||||
/// Returns a [Comparator] that asserts that its first argument is comparable.
|
||||
@ -202,9 +200,9 @@ Comparator<T> _defaultCompare<T>() {
|
||||
/// they started in.
|
||||
void _insertionSort<T>(
|
||||
List<T> list, {
|
||||
int Function(T, T) compare,
|
||||
int Function(T, T)? compare,
|
||||
int start = 0,
|
||||
int end,
|
||||
int? end,
|
||||
}) {
|
||||
// If the same method could have both positional and named optional
|
||||
// parameters, this should be (list, [start, end], {compare}).
|
||||
@ -238,7 +236,7 @@ void _movingInsertionSort<T>(
|
||||
int Function(T, T) compare,
|
||||
int start,
|
||||
int end,
|
||||
List<T> target,
|
||||
List<T?> target,
|
||||
int targetOffset,
|
||||
) {
|
||||
final int length = end - start;
|
||||
@ -252,7 +250,7 @@ void _movingInsertionSort<T>(
|
||||
int max = targetOffset + i;
|
||||
while (min < max) {
|
||||
final int mid = min + ((max - min) >> 1);
|
||||
if (compare(element, target[mid]) < 0) {
|
||||
if (compare(element, target[mid] as T) < 0) {
|
||||
max = mid;
|
||||
} else {
|
||||
min = mid + 1;
|
||||
@ -275,12 +273,12 @@ void _mergeSort<T>(
|
||||
int Function(T, T) compare,
|
||||
int start,
|
||||
int end,
|
||||
List<T> target,
|
||||
List<T?> target,
|
||||
int targetOffset,
|
||||
) {
|
||||
final int length = end - start;
|
||||
if (length < _kMergeSortLimit) {
|
||||
_movingInsertionSort(list, compare, start, end, target, targetOffset);
|
||||
_movingInsertionSort<T>(list, compare, start, end, target, targetOffset);
|
||||
return;
|
||||
}
|
||||
final int middle = start + (length >> 1);
|
||||
@ -289,11 +287,11 @@ void _mergeSort<T>(
|
||||
// Here secondLength >= firstLength (differs by at most one).
|
||||
final int targetMiddle = targetOffset + firstLength;
|
||||
// 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.
|
||||
_mergeSort(list, compare, start, middle, list, middle);
|
||||
_mergeSort<T>(list, compare, start, middle, list, middle);
|
||||
// Merge the two parts into the target area.
|
||||
_merge(
|
||||
_merge<T>(
|
||||
compare,
|
||||
list,
|
||||
middle,
|
||||
@ -318,10 +316,10 @@ void _merge<T>(
|
||||
List<T> firstList,
|
||||
int firstStart,
|
||||
int firstEnd,
|
||||
List<T> secondList,
|
||||
List<T?> secondList,
|
||||
int secondStart,
|
||||
int secondEnd,
|
||||
List<T> target,
|
||||
List<T?> target,
|
||||
int targetOffset,
|
||||
) {
|
||||
// No empty lists reaches here.
|
||||
@ -330,7 +328,7 @@ void _merge<T>(
|
||||
int cursor1 = firstStart;
|
||||
int cursor2 = secondStart;
|
||||
T firstElement = firstList[cursor1++];
|
||||
T secondElement = secondList[cursor2++];
|
||||
T secondElement = secondList[cursor2++] as T;
|
||||
while (true) {
|
||||
if (compare(firstElement, secondElement) <= 0) {
|
||||
target[targetOffset++] = firstElement;
|
||||
@ -342,7 +340,7 @@ void _merge<T>(
|
||||
} else {
|
||||
target[targetOffset++] = secondElement;
|
||||
if (cursor2 != secondEnd) {
|
||||
secondElement = secondList[cursor2++];
|
||||
secondElement = secondList[cursor2++] as T;
|
||||
continue;
|
||||
}
|
||||
// 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
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:convert';
|
||||
import 'dart:io';
|
||||
@ -25,7 +23,7 @@ import 'dart:typed_data';
|
||||
/// until the request has been fully processed).
|
||||
///
|
||||
/// 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
|
||||
/// [Uint8List].
|
||||
@ -48,14 +46,14 @@ typedef BytesReceivedCallback = void Function(int cumulative, int total);
|
||||
Future<Uint8List> consolidateHttpClientResponseBytes(
|
||||
HttpClientResponse response, {
|
||||
bool autoUncompress = true,
|
||||
BytesReceivedCallback onBytesReceived,
|
||||
BytesReceivedCallback? onBytesReceived,
|
||||
}) {
|
||||
assert(autoUncompress != null);
|
||||
final Completer<Uint8List> completer = Completer<Uint8List>.sync();
|
||||
|
||||
final _OutputBuffer output = _OutputBuffer();
|
||||
ByteConversionSink sink = output;
|
||||
int expectedContentLength = response.contentLength;
|
||||
int? expectedContentLength = response.contentLength;
|
||||
if (expectedContentLength == -1)
|
||||
expectedContentLength = null;
|
||||
switch (response.compressionState) {
|
||||
@ -76,7 +74,7 @@ Future<Uint8List> consolidateHttpClientResponseBytes(
|
||||
}
|
||||
|
||||
int bytesReceived = 0;
|
||||
StreamSubscription<List<int>> subscription;
|
||||
late final StreamSubscription<List<int>> subscription;
|
||||
subscription = response.listen((List<int> chunk) {
|
||||
sink.add(chunk);
|
||||
if (onBytesReceived != null) {
|
||||
@ -98,14 +96,14 @@ Future<Uint8List> consolidateHttpClientResponseBytes(
|
||||
}
|
||||
|
||||
class _OutputBuffer extends ByteConversionSinkBase {
|
||||
List<List<int>> _chunks = <List<int>>[];
|
||||
List<List<int>>? _chunks = <List<int>>[];
|
||||
int _contentLength = 0;
|
||||
Uint8List _bytes;
|
||||
Uint8List? _bytes;
|
||||
|
||||
@override
|
||||
void add(List<int> chunk) {
|
||||
assert(_bytes == null);
|
||||
_chunks.add(chunk);
|
||||
_chunks!.add(chunk);
|
||||
_contentLength += chunk.length;
|
||||
}
|
||||
|
||||
@ -117,8 +115,8 @@ class _OutputBuffer extends ByteConversionSinkBase {
|
||||
}
|
||||
_bytes = Uint8List(_contentLength);
|
||||
int offset = 0;
|
||||
for (final List<int> chunk in _chunks) {
|
||||
_bytes.setRange(offset, offset + chunk.length, chunk);
|
||||
for (final List<int> chunk in _chunks!) {
|
||||
_bytes!.setRange(offset, offset + chunk.length, chunk);
|
||||
offset += chunk.length;
|
||||
}
|
||||
_chunks = null;
|
||||
@ -126,6 +124,6 @@ class _OutputBuffer extends ByteConversionSinkBase {
|
||||
|
||||
Uint8List get bytes {
|
||||
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
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
/// 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
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:ui' as ui show Brightness;
|
||||
|
||||
@ -54,7 +52,7 @@ bool debugInstrumentationEnabled = false;
|
||||
/// * [Timeline], which is used to record synchronous tracing events for
|
||||
/// visualization in Chrome's tracing format. This method does not
|
||||
/// 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;
|
||||
assert(() {
|
||||
instrument = debugInstrumentationEnabled;
|
||||
@ -62,10 +60,12 @@ Future<T> debugInstrumentAction<T>(String description, Future<T> action()) {
|
||||
}());
|
||||
if (instrument) {
|
||||
final Stopwatch stopwatch = Stopwatch()..start();
|
||||
return action().whenComplete(() {
|
||||
try {
|
||||
return await action();
|
||||
} finally {
|
||||
stopwatch.stop();
|
||||
debugPrint('Action "$description" took ${stopwatch.elapsed}');
|
||||
});
|
||||
}
|
||||
} else {
|
||||
return action();
|
||||
}
|
||||
@ -87,17 +87,17 @@ const Map<String, String> timelineArgumentsIndicatingLandmarkEvent = <String, St
|
||||
/// Configure [debugFormatDouble] using [num.toStringAsPrecision].
|
||||
///
|
||||
/// Defaults to null, which uses the default logic of [debugFormatDouble].
|
||||
int debugDoublePrecision;
|
||||
int? debugDoublePrecision;
|
||||
|
||||
/// Formats a double to have standard formatting.
|
||||
///
|
||||
/// This behavior can be overridden by [debugDoublePrecision].
|
||||
String debugFormatDouble(double value) {
|
||||
String debugFormatDouble(double? value) {
|
||||
if (value == null) {
|
||||
return 'null';
|
||||
}
|
||||
if (debugDoublePrecision != null) {
|
||||
return value.toStringAsPrecision(debugDoublePrecision);
|
||||
return value.toStringAsPrecision(debugDoublePrecision!);
|
||||
}
|
||||
return value.toStringAsFixed(1);
|
||||
}
|
||||
@ -109,4 +109,4 @@ String debugFormatDouble(double value) {
|
||||
///
|
||||
/// * [WidgetsApp], which uses the [debugBrightnessOverride] setting in debug mode
|
||||
/// 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
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import '_isolates_io.dart'
|
||||
@ -20,7 +18,7 @@ import '_isolates_io.dart'
|
||||
typedef ComputeCallback<Q, R> = FutureOr<R> Function(Q message);
|
||||
|
||||
// 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
|
||||
/// (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
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:ui' show hashValues;
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
import 'package:meta/meta.dart' show visibleForTesting;
|
||||
@ -49,7 +47,7 @@ abstract class LicenseEntry {
|
||||
const LicenseEntry();
|
||||
|
||||
/// 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
|
||||
/// a string and some formatting information. Paragraphs can include newline
|
||||
@ -125,7 +123,7 @@ class LicenseEntryWithLineBreaks extends LicenseEntry {
|
||||
const LicenseEntryWithLineBreaks(this.packages, this.text);
|
||||
|
||||
@override
|
||||
final List<String> packages;
|
||||
final List<String>? packages;
|
||||
|
||||
/// The text of the license.
|
||||
///
|
||||
@ -148,7 +146,7 @@ class LicenseEntryWithLineBreaks extends LicenseEntry {
|
||||
int currentPosition = 0;
|
||||
int lastLineIndent = 0;
|
||||
int currentLineIndent = 0;
|
||||
int currentParagraphIndentation;
|
||||
int? currentParagraphIndentation;
|
||||
_LicenseEntryWithLineBreaksParserState state = _LicenseEntryWithLineBreaksParserState.beforeParagraph;
|
||||
final List<String> lines = <String>[];
|
||||
|
||||
@ -160,7 +158,7 @@ class LicenseEntryWithLineBreaks extends LicenseEntry {
|
||||
LicenseParagraph getParagraph() {
|
||||
assert(lines.isNotEmpty);
|
||||
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.isNotEmpty);
|
||||
lines.clear();
|
||||
@ -295,7 +293,7 @@ class LicenseRegistry {
|
||||
// ignore: unused_element
|
||||
LicenseRegistry._();
|
||||
|
||||
static List<LicenseEntryCollector> _collectors;
|
||||
static List<LicenseEntryCollector>? _collectors;
|
||||
|
||||
/// Adds licenses to the registry.
|
||||
///
|
||||
@ -306,7 +304,7 @@ class LicenseRegistry {
|
||||
/// licenses, the closure will not be called.
|
||||
static void addLicense(LicenseEntryCollector collector) {
|
||||
_collectors ??= <LicenseEntryCollector>[];
|
||||
_collectors.add(collector);
|
||||
_collectors!.add(collector);
|
||||
}
|
||||
|
||||
/// Returns the licenses that have been registered.
|
||||
@ -315,7 +313,7 @@ class LicenseRegistry {
|
||||
static Stream<LicenseEntry> get licenses async* {
|
||||
if (_collectors == null)
|
||||
return;
|
||||
for (final LicenseEntryCollector collector in _collectors)
|
||||
for (final LicenseEntryCollector collector in _collectors!)
|
||||
yield* collector();
|
||||
}
|
||||
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:meta/meta.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 entire subtree that this node belongs to will have the same owner.
|
||||
Object get owner => _owner;
|
||||
Object _owner;
|
||||
Object? get owner => _owner;
|
||||
Object? _owner;
|
||||
|
||||
/// Whether this node is in a tree whose root is attached to something.
|
||||
///
|
||||
@ -107,12 +105,12 @@ class AbstractNode {
|
||||
void detach() {
|
||||
assert(_owner != null);
|
||||
_owner = null;
|
||||
assert(parent == null || attached == parent.attached);
|
||||
assert(parent == null || attached == parent!.attached);
|
||||
}
|
||||
|
||||
/// The parent of this node in the tree.
|
||||
AbstractNode get parent => _parent;
|
||||
AbstractNode _parent;
|
||||
AbstractNode? get parent => _parent;
|
||||
AbstractNode? _parent;
|
||||
|
||||
/// Mark the given node as being a child of this node.
|
||||
///
|
||||
@ -125,13 +123,13 @@ class AbstractNode {
|
||||
assert(() {
|
||||
AbstractNode node = this;
|
||||
while (node.parent != null)
|
||||
node = node.parent;
|
||||
node = node.parent!;
|
||||
assert(node != child); // indicates we are about to create a cycle
|
||||
return true;
|
||||
}());
|
||||
child._parent = this;
|
||||
if (attached)
|
||||
child.attach(_owner);
|
||||
child.attach(_owner!);
|
||||
redepthChild(child);
|
||||
}
|
||||
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
/// Framework code should use this method in favor of calling `toString` on
|
||||
/// [Object.runtimeType].
|
||||
///
|
||||
@ -11,7 +9,7 @@
|
||||
/// negatively impact performance. If asserts are enabled, this method will
|
||||
/// return `object.runtimeType.toString()`; otherwise, it will return the
|
||||
/// [optimizedValue], which must be a simple constant string.
|
||||
String objectRuntimeType(Object object, String optimizedValue) {
|
||||
String objectRuntimeType(Object? object, String optimizedValue) {
|
||||
assert(() {
|
||||
optimizedValue = object.runtimeType.toString();
|
||||
return true;
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:collection';
|
||||
|
||||
/// 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> {
|
||||
final List<T> _list = <T>[];
|
||||
bool _isDirty = false;
|
||||
HashSet<T> _set;
|
||||
late final HashSet<T> _set = HashSet<T>();
|
||||
|
||||
/// 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.
|
||||
bool remove(T item) {
|
||||
_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);
|
||||
}
|
||||
|
||||
@override
|
||||
bool contains(Object element) {
|
||||
bool contains(Object? element) {
|
||||
if (_list.length < 3)
|
||||
return _list.contains(element);
|
||||
|
||||
if (_isDirty) {
|
||||
if (_set == null) {
|
||||
_set = HashSet<T>.from(_list);
|
||||
} else {
|
||||
_set.addAll(_list);
|
||||
}
|
||||
_set.addAll(_list);
|
||||
_isDirty = false;
|
||||
}
|
||||
|
||||
@ -107,7 +101,7 @@ class HashedObserverList<T> extends Iterable<T> {
|
||||
///
|
||||
/// Returns whether the item was present in the list.
|
||||
bool remove(T item) {
|
||||
final int value = _map[item];
|
||||
final int? value = _map[item];
|
||||
if (value == null) {
|
||||
return false;
|
||||
}
|
||||
@ -120,7 +114,7 @@ class HashedObserverList<T> extends Iterable<T> {
|
||||
}
|
||||
|
||||
@override
|
||||
bool contains(Object element) => _map.containsKey(element);
|
||||
bool contains(Object? element) => _map.containsKey(element);
|
||||
|
||||
@override
|
||||
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
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import '_platform_io.dart'
|
||||
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.
|
||||
///
|
||||
/// 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
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:async';
|
||||
import 'dart:collection';
|
||||
|
||||
/// 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"
|
||||
/// tool's "logs" command ("flutter logs").
|
||||
@ -32,8 +30,8 @@ DebugPrintCallback debugPrint = debugPrintThrottled;
|
||||
|
||||
/// Alternative implementation of [debugPrint] that does not throttle.
|
||||
/// Used by tests.
|
||||
void debugPrintSynchronously(String message, { int wrapWidth }) {
|
||||
if (wrapWidth != null) {
|
||||
void debugPrintSynchronously(String? message, { int? wrapWidth }) {
|
||||
if (message != null && wrapWidth != null) {
|
||||
print(message.split('\n').expand<String>((String line) => debugWordWrap(line, wrapWidth)).join('\n'));
|
||||
} else {
|
||||
print(message);
|
||||
@ -42,7 +40,7 @@ void debugPrintSynchronously(String message, { int wrapWidth }) {
|
||||
|
||||
/// Implementation of [debugPrint] that throttles messages. This avoids dropping
|
||||
/// messages on platforms that rate-limit their logging (for example, Android).
|
||||
void debugPrintThrottled(String message, { int wrapWidth }) {
|
||||
void debugPrintThrottled(String? message, { int? wrapWidth }) {
|
||||
final List<String> messageLines = message?.split('\n') ?? <String>['null'];
|
||||
if (wrapWidth != null) {
|
||||
_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);
|
||||
final Queue<String> _debugPrintBuffer = Queue<String>();
|
||||
final Stopwatch _debugPrintStopwatch = Stopwatch();
|
||||
Completer<void> _debugPrintCompleter;
|
||||
Completer<void>? _debugPrintCompleter;
|
||||
bool _debugPrintScheduled = false;
|
||||
void _debugPrintTask() {
|
||||
_debugPrintScheduled = false;
|
||||
@ -112,15 +110,15 @@ Iterable<String> debugWordWrap(String message, int width, { String wrapIndent =
|
||||
yield message;
|
||||
return;
|
||||
}
|
||||
final Match prefixMatch = _indentPattern.matchAsPrefix(message);
|
||||
final String prefix = wrapIndent + ' ' * prefixMatch.group(0).length;
|
||||
final Match prefixMatch = _indentPattern.matchAsPrefix(message)!;
|
||||
final String prefix = wrapIndent + ' ' * prefixMatch.group(0)!.length;
|
||||
int start = 0;
|
||||
int startForLengthCalculations = 0;
|
||||
bool addPrefix = false;
|
||||
int index = prefix.length;
|
||||
_WordWrapParseMode mode = _WordWrapParseMode.inSpace;
|
||||
int lastWordStart;
|
||||
int lastWordEnd;
|
||||
late int lastWordStart;
|
||||
int? lastWordEnd;
|
||||
while (true) {
|
||||
switch (mode) {
|
||||
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
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:typed_data';
|
||||
|
||||
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.
|
||||
class WriteBuffer {
|
||||
/// Creates an interface for incrementally building a [ByteData] instance.
|
||||
WriteBuffer() {
|
||||
_buffer = Uint8Buffer();
|
||||
_eightBytes = ByteData(8);
|
||||
WriteBuffer()
|
||||
: _buffer = Uint8Buffer(),
|
||||
_eightBytes = ByteData(8) {
|
||||
_eightBytesAsList = _eightBytes.buffer.asUint8List();
|
||||
}
|
||||
|
||||
Uint8Buffer _buffer;
|
||||
ByteData _eightBytes;
|
||||
Uint8List _eightBytesAsList;
|
||||
Uint8Buffer? _buffer;
|
||||
final ByteData _eightBytes;
|
||||
late Uint8List _eightBytesAsList;
|
||||
|
||||
/// Write a Uint8 into the buffer.
|
||||
void putUint8(int byte) {
|
||||
_buffer.add(byte);
|
||||
_buffer!.add(byte);
|
||||
}
|
||||
|
||||
/// 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);
|
||||
_buffer.addAll(_eightBytesAsList, 0, 2);
|
||||
_buffer!.addAll(_eightBytesAsList, 0, 2);
|
||||
}
|
||||
|
||||
/// 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);
|
||||
_buffer.addAll(_eightBytesAsList, 0, 4);
|
||||
_buffer!.addAll(_eightBytesAsList, 0, 4);
|
||||
}
|
||||
|
||||
/// 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);
|
||||
_buffer.addAll(_eightBytesAsList, 0, 4);
|
||||
_buffer!.addAll(_eightBytesAsList, 0, 4);
|
||||
}
|
||||
|
||||
/// 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);
|
||||
_buffer.addAll(_eightBytesAsList, 0, 8);
|
||||
_buffer!.addAll(_eightBytesAsList, 0, 8);
|
||||
}
|
||||
|
||||
/// Write an Float64 into the buffer.
|
||||
void putFloat64(double value, {Endian endian}) {
|
||||
void putFloat64(double value, {Endian? endian}) {
|
||||
_alignTo(8);
|
||||
_eightBytes.setFloat64(0, value, endian ?? Endian.host);
|
||||
_buffer.addAll(_eightBytesAsList);
|
||||
_buffer!.addAll(_eightBytesAsList);
|
||||
}
|
||||
|
||||
/// Write all the values from a [Uint8List] into the buffer.
|
||||
void putUint8List(Uint8List list) {
|
||||
_buffer.addAll(list);
|
||||
_buffer!.addAll(list);
|
||||
}
|
||||
|
||||
/// Write all the values from an [Int32List] into the buffer.
|
||||
void putInt32List(Int32List list) {
|
||||
_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.
|
||||
void putInt64List(Int64List list) {
|
||||
_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.
|
||||
void putFloat64List(Float64List list) {
|
||||
_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) {
|
||||
final int mod = _buffer.length % alignment;
|
||||
final int mod = _buffer!.length % alignment;
|
||||
if (mod != 0) {
|
||||
for (int i = 0; i < alignment - mod; i++)
|
||||
_buffer.add(0);
|
||||
_buffer!.add(0);
|
||||
}
|
||||
}
|
||||
|
||||
/// Finalize and return the written [ByteData].
|
||||
ByteData done() {
|
||||
final ByteData result = _buffer.buffer.asByteData(0, _buffer.lengthInBytes);
|
||||
final ByteData result = _buffer!.buffer.asByteData(0, _buffer!.lengthInBytes);
|
||||
_buffer = null;
|
||||
return result;
|
||||
}
|
||||
@ -124,35 +122,35 @@ class ReadBuffer {
|
||||
}
|
||||
|
||||
/// Reads a Uint16 from the buffer.
|
||||
int getUint16({Endian endian}) {
|
||||
int getUint16({Endian? endian}) {
|
||||
final int value = data.getUint16(_position, endian ?? Endian.host);
|
||||
_position += 2;
|
||||
return value;
|
||||
}
|
||||
|
||||
/// Reads a Uint32 from the buffer.
|
||||
int getUint32({Endian endian}) {
|
||||
int getUint32({Endian? endian}) {
|
||||
final int value = data.getUint32(_position, endian ?? Endian.host);
|
||||
_position += 4;
|
||||
return value;
|
||||
}
|
||||
|
||||
/// Reads an Int32 from the buffer.
|
||||
int getInt32({Endian endian}) {
|
||||
int getInt32({Endian? endian}) {
|
||||
final int value = data.getInt32(_position, endian ?? Endian.host);
|
||||
_position += 4;
|
||||
return value;
|
||||
}
|
||||
|
||||
/// Reads an Int64 from the buffer.
|
||||
int getInt64({Endian endian}) {
|
||||
int getInt64({Endian? endian}) {
|
||||
final int value = data.getInt64(_position, endian ?? Endian.host);
|
||||
_position += 8;
|
||||
return value;
|
||||
}
|
||||
|
||||
/// Reads a Float64 from the buffer.
|
||||
double getFloat64({Endian endian}) {
|
||||
double getFloat64({Endian? endian}) {
|
||||
_alignTo(8);
|
||||
final double value = data.getFloat64(_position, endian ?? Endian.host);
|
||||
_position += 8;
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:ui' show hashValues;
|
||||
|
||||
import 'package:meta/meta.dart';
|
||||
@ -29,16 +27,16 @@ class StackFrame {
|
||||
/// 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).
|
||||
const StackFrame({
|
||||
@required this.number,
|
||||
@required this.column,
|
||||
@required this.line,
|
||||
@required this.packageScheme,
|
||||
@required this.package,
|
||||
@required this.packagePath,
|
||||
required this.number,
|
||||
required this.column,
|
||||
required this.line,
|
||||
required this.packageScheme,
|
||||
required this.package,
|
||||
required this.packagePath,
|
||||
this.className = '',
|
||||
@required this.method,
|
||||
required this.method,
|
||||
this.isConstructor = false,
|
||||
@required this.source,
|
||||
required this.source,
|
||||
}) : assert(number != null),
|
||||
assert(column != null),
|
||||
assert(line != null),
|
||||
@ -92,11 +90,11 @@ class StackFrame {
|
||||
// On the Web in non-debug builds the stack trace includes the exception
|
||||
// message that precedes the stack trace itself. fromStackTraceLine will
|
||||
// return null in that case. We will skip it here.
|
||||
.skipWhile((StackFrame frame) => frame == null)
|
||||
.whereType<StackFrame>()
|
||||
.toList();
|
||||
}
|
||||
|
||||
static StackFrame _parseWebFrame(String line) {
|
||||
static StackFrame? _parseWebFrame(String line) {
|
||||
if (kDebugMode) {
|
||||
return _parseWebDebugFrame(line);
|
||||
} else {
|
||||
@ -111,15 +109,16 @@ class StackFrame {
|
||||
final RegExp parser = hasPackage
|
||||
? RegExp(r'^(package.+) (\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.');
|
||||
match = match!;
|
||||
|
||||
String package = '<unknown>';
|
||||
String packageScheme = '<unknown>';
|
||||
String packagePath = '<unknown>';
|
||||
if (hasPackage) {
|
||||
packageScheme = 'package';
|
||||
final Uri packageUri = Uri.parse(match.group(1));
|
||||
final Uri packageUri = Uri.parse(match.group(1)!);
|
||||
package = packageUri.pathSegments[0];
|
||||
packagePath = packageUri.path.replaceFirst(packageUri.pathSegments[0] + '/', '');
|
||||
}
|
||||
@ -129,10 +128,10 @@ class StackFrame {
|
||||
packageScheme: packageScheme,
|
||||
package: package,
|
||||
packagePath: packagePath,
|
||||
line: int.parse(match.group(2)),
|
||||
column: int.parse(match.group(3)),
|
||||
line: int.parse(match.group(2)!),
|
||||
column: int.parse(match.group(3)!),
|
||||
className: '<unknown>',
|
||||
method: match.group(4),
|
||||
method: match.group(4)!,
|
||||
source: line,
|
||||
);
|
||||
}
|
||||
@ -145,8 +144,8 @@ class StackFrame {
|
||||
|
||||
// Parses `line` as a stack frame in profile and release Web builds. If not
|
||||
// recognized as a stack frame, returns null.
|
||||
static StackFrame _parseWebNonDebugFrame(String line) {
|
||||
final Match match = _webNonDebugFramePattern.firstMatch(line);
|
||||
static StackFrame? _parseWebNonDebugFrame(String line) {
|
||||
final Match? match = _webNonDebugFramePattern.firstMatch(line);
|
||||
if (match == null) {
|
||||
// On the Web in non-debug builds the stack trace includes the exception
|
||||
// message that precedes the stack trace itself. Example:
|
||||
@ -162,7 +161,7 @@ class StackFrame {
|
||||
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 method = classAndMethod.length > 1
|
||||
? classAndMethod.skip(1).join('.')
|
||||
@ -182,7 +181,7 @@ class StackFrame {
|
||||
}
|
||||
|
||||
/// Parses a single [StackFrame] from a single line of a [StackTrace].
|
||||
static StackFrame fromStackTraceLine(String line) {
|
||||
static StackFrame? fromStackTraceLine(String line) {
|
||||
assert(line != null);
|
||||
if (line == '<asynchronous suspension>') {
|
||||
return asynchronousSuspension;
|
||||
@ -203,12 +202,13 @@ class StackFrame {
|
||||
}
|
||||
|
||||
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.');
|
||||
match = match!;
|
||||
|
||||
bool isConstructor = false;
|
||||
String className = '';
|
||||
String method = match.group(2).replaceAll('.<anonymous closure>', '');
|
||||
String method = match.group(2)!.replaceAll('.<anonymous closure>', '');
|
||||
if (method.startsWith('new')) {
|
||||
className = method.split(' ')[1];
|
||||
method = '';
|
||||
@ -224,7 +224,7 @@ class StackFrame {
|
||||
method = parts[1];
|
||||
}
|
||||
|
||||
final Uri packageUri = Uri.parse(match.group(3));
|
||||
final Uri packageUri = Uri.parse(match.group(3)!);
|
||||
String package = '<unknown>';
|
||||
String packagePath = packageUri.path;
|
||||
if (packageUri.scheme == 'dart' || packageUri.scheme == 'package') {
|
||||
@ -233,14 +233,14 @@ class StackFrame {
|
||||
}
|
||||
|
||||
return StackFrame(
|
||||
number: int.parse(match.group(1)),
|
||||
number: int.parse(match.group(1)!),
|
||||
className: className,
|
||||
method: method,
|
||||
packageScheme: packageUri.scheme,
|
||||
package: package,
|
||||
packagePath: packagePath,
|
||||
line: match.group(4) == null ? -1 : int.parse(match.group(4)),
|
||||
column: match.group(5) == null ? -1 : int.parse(match.group(5)),
|
||||
line: match.group(4) == null ? -1 : int.parse(match.group(4)!),
|
||||
column: match.group(5) == null ? -1 : int.parse(match.group(5)!),
|
||||
isConstructor: isConstructor,
|
||||
source: line,
|
||||
);
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'dart:async';
|
||||
|
||||
/// A [Future] whose [then] implementation calls the callback immediately.
|
||||
@ -36,18 +34,18 @@ class SynchronousFuture<T> implements Future<T> {
|
||||
}
|
||||
|
||||
@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
|
||||
Future<E> then<E>(FutureOr<E> f(T value), { Function onError }) {
|
||||
final dynamic result = f(_value);
|
||||
if (result is Future<E>)
|
||||
Future<R> then<R>(FutureOr<R> onValue(T value), { Function? onError }) {
|
||||
final dynamic result = onValue(_value);
|
||||
if (result is Future<R>)
|
||||
return result;
|
||||
return SynchronousFuture<E>(result as E);
|
||||
return SynchronousFuture<R>(result as R);
|
||||
}
|
||||
|
||||
@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);
|
||||
}
|
||||
|
||||
|
@ -2,8 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
/// Constants for useful Unicode characters.
|
||||
///
|
||||
/// 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
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:flutter/rendering.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
|
Loading…
x
Reference in New Issue
Block a user