@@ -1897,7 +1897,7 @@ abstract class _NumProperty<T extends num> extends DiagnosticsProperty<T> {
|
||||
|
||||
_NumProperty.lazy(
|
||||
String name,
|
||||
ComputePropertyValueCallback<T> computeValue, {
|
||||
ComputePropertyValueCallback<T?> computeValue, {
|
||||
String? ifNull,
|
||||
this.unit,
|
||||
bool showName = true,
|
||||
@@ -1984,7 +1984,7 @@ class DoubleProperty extends _NumProperty<double> {
|
||||
/// The [showName] and [level] arguments must not be null.
|
||||
DoubleProperty.lazy(
|
||||
String name,
|
||||
ComputePropertyValueCallback<double> computeValue, {
|
||||
ComputePropertyValueCallback<double?> computeValue, {
|
||||
String? ifNull,
|
||||
bool showName = true,
|
||||
String? unit,
|
||||
@@ -2480,7 +2480,7 @@ class ObjectFlagProperty<T> extends DiagnosticsProperty<T> {
|
||||
/// only one flag, and is preferred if there is only one entry.
|
||||
/// * [IterableProperty], which provides similar functionality describing
|
||||
/// the values a collection of objects.
|
||||
class FlagsSummary<T> extends DiagnosticsProperty<Map<String, T>> {
|
||||
class FlagsSummary<T> extends DiagnosticsProperty<Map<String, T?>> {
|
||||
/// Create a summary for multiple properties, indicating whether each of them
|
||||
/// is present (non-null) or absent (null).
|
||||
///
|
||||
@@ -2488,7 +2488,7 @@ class FlagsSummary<T> extends DiagnosticsProperty<Map<String, T>> {
|
||||
/// null.
|
||||
FlagsSummary(
|
||||
String name,
|
||||
Map<String, T> value, {
|
||||
Map<String, T?> value, {
|
||||
String? ifEmpty,
|
||||
bool showName = true,
|
||||
bool showSeparator = true,
|
||||
@@ -2507,7 +2507,7 @@ class FlagsSummary<T> extends DiagnosticsProperty<Map<String, T>> {
|
||||
);
|
||||
|
||||
@override
|
||||
Map<String, T> get value => super.value!;
|
||||
Map<String, T?> get value => super.value!;
|
||||
|
||||
@override
|
||||
String valueToString({TextTreeConfiguration? parentConfiguration}) {
|
||||
@@ -2545,7 +2545,7 @@ class FlagsSummary<T> extends DiagnosticsProperty<Map<String, T>> {
|
||||
return json;
|
||||
}
|
||||
|
||||
bool _hasNonNullEntry() => value.values.any((T o) => o != null);
|
||||
bool _hasNonNullEntry() => value.values.any((T? o) => o != null);
|
||||
|
||||
// An iterable of each entry's description in [value].
|
||||
//
|
||||
@@ -2554,7 +2554,7 @@ class FlagsSummary<T> extends DiagnosticsProperty<Map<String, T>> {
|
||||
// For a null value, it is omitted unless `includeEmtpy` is true and
|
||||
// [ifEntryNull] contains a corresponding description.
|
||||
Iterable<String> _formattedValues() sync* {
|
||||
for (final MapEntry<String, T> entry in value.entries) {
|
||||
for (final MapEntry<String, T?> entry in value.entries) {
|
||||
if (entry.value != null) {
|
||||
yield entry.key;
|
||||
}
|
||||
@@ -2567,7 +2567,7 @@ class FlagsSummary<T> extends DiagnosticsProperty<Map<String, T>> {
|
||||
/// May throw exception if accessing the property would throw an exception
|
||||
/// and callers must handle that case gracefully. For example, accessing a
|
||||
/// property may trigger an assert that layout constraints were violated.
|
||||
typedef ComputePropertyValueCallback<T> = T Function();
|
||||
typedef ComputePropertyValueCallback<T> = T? Function();
|
||||
|
||||
/// Property with a [value] of type [T].
|
||||
///
|
||||
@@ -2651,7 +2651,7 @@ class DiagnosticsProperty<T> extends DiagnosticsNode {
|
||||
DiagnosticLevel level = DiagnosticLevel.info,
|
||||
}) : assert(showName != null),
|
||||
assert(showSeparator != null),
|
||||
assert(defaultValue == kNoDefaultValue || defaultValue is T),
|
||||
assert(defaultValue == kNoDefaultValue || defaultValue is T?),
|
||||
assert(missingIfNull != null),
|
||||
assert(style != null),
|
||||
assert(level != null),
|
||||
@@ -2848,7 +2848,8 @@ class DiagnosticsProperty<T> extends DiagnosticsNode {
|
||||
/// of the property is downgraded to [DiagnosticLevel.fine] as the property
|
||||
/// value is uninteresting.
|
||||
///
|
||||
/// [defaultValue] has type [T] or is [kNoDefaultValue].
|
||||
/// The [defaultValue] is [kNoDefaultValue] by default. Otherwise it must be of
|
||||
/// type `T?`.
|
||||
final Object? defaultValue;
|
||||
|
||||
final DiagnosticLevel _defaultLevel;
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
|
||||
import 'dart:ui' as ui show AccessibilityFeatures, SemanticsUpdateBuilder;
|
||||
|
||||
import 'package:flutter/foundation.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:ui' as ui;
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
@@ -19,7 +17,7 @@ import '../scheduler/scheduler_tester.dart';
|
||||
void main() {
|
||||
setUp(() {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
WidgetsBinding.instance.resetEpoch();
|
||||
WidgetsBinding.instance!.resetEpoch();
|
||||
ui.window.onBeginFrame = null;
|
||||
ui.window.onDrawFrame = null;
|
||||
});
|
||||
@@ -350,7 +348,7 @@ void main() {
|
||||
expect(controller.repeat, throwsFlutterError);
|
||||
|
||||
controller.dispose();
|
||||
FlutterError result;
|
||||
FlutterError? result;
|
||||
try {
|
||||
controller.dispose();
|
||||
} on FlutterError catch (e) {
|
||||
@@ -358,7 +356,7 @@ void main() {
|
||||
}
|
||||
expect(result, isNotNull);
|
||||
expect(
|
||||
result.toStringDeep(),
|
||||
result!.toStringDeep(),
|
||||
equalsIgnoringHashCodes(
|
||||
'FlutterError\n'
|
||||
' AnimationController.dispose() called more than once.\n'
|
||||
@@ -482,7 +480,7 @@ void main() {
|
||||
controller.forward(from: 0.2);
|
||||
expect(controller.value, 0.2);
|
||||
controller.animateTo(1.0, duration: Duration.zero);
|
||||
expect(SchedulerBinding.instance.transientCallbackCount, equals(0), reason: 'Expected no animation.');
|
||||
expect(SchedulerBinding.instance!.transientCallbackCount, equals(0), reason: 'Expected no animation.');
|
||||
expect(controller.value, 1.0);
|
||||
});
|
||||
|
||||
|
||||
@@ -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';
|
||||
|
||||
import 'package:flutter/cupertino.dart';
|
||||
@@ -84,8 +82,8 @@ class _DecuplePixels extends StatefulWidget {
|
||||
State<StatefulWidget> createState() => _DecuplePixelsState();
|
||||
}
|
||||
|
||||
class _DecuplePixelsState extends State<_DecuplePixels> with SingleTickerProviderStateMixin {
|
||||
AnimationController _controller;
|
||||
class _DecuplePixelsState extends State<_DecuplePixels> with SingleTickerProviderStateMixin<_DecuplePixels> {
|
||||
late AnimationController _controller;
|
||||
|
||||
@override
|
||||
void initState() {
|
||||
@@ -107,7 +105,7 @@ class _DecuplePixelsState extends State<_DecuplePixels> with SingleTickerProvide
|
||||
Widget build(BuildContext context) {
|
||||
return AnimatedBuilder(
|
||||
animation: _controller.view,
|
||||
builder: (BuildContext context, Widget child) {
|
||||
builder: (BuildContext context, Widget? child) {
|
||||
return CustomPaint(
|
||||
painter: _PaintDecuplePixels(_controller.value),
|
||||
);
|
||||
@@ -132,7 +130,7 @@ class _PaintDecuplePixels extends CustomPainter {
|
||||
final Rect rect = RectTween(
|
||||
begin: const Rect.fromLTWH(1, 1, 1, 1),
|
||||
end: const Rect.fromLTWH(11, 1, 1, 1),
|
||||
).transform(value);
|
||||
).transform(value)!;
|
||||
canvas.drawRect(rect, Paint()..color = Colors.yellow);
|
||||
final Paint black = Paint()..color = Colors.black;
|
||||
canvas
|
||||
|
||||
@@ -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' as ui;
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
@@ -21,7 +19,7 @@ class BogusCurve extends Curve {
|
||||
void main() {
|
||||
setUp(() {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
WidgetsBinding.instance.resetEpoch();
|
||||
WidgetsBinding.instance!.resetEpoch();
|
||||
ui.window.onBeginFrame = null;
|
||||
ui.window.onDrawFrame = null;
|
||||
});
|
||||
@@ -240,14 +238,14 @@ void main() {
|
||||
vsync: const TestVSync(),
|
||||
);
|
||||
final CurvedAnimation curved = CurvedAnimation(parent: controller, curve: BogusCurve());
|
||||
FlutterError error;
|
||||
FlutterError? error;
|
||||
try {
|
||||
curved.value;
|
||||
} on FlutterError catch (e) {
|
||||
error = e;
|
||||
}
|
||||
expect(error, isNotNull);
|
||||
expect(error.toStringDeep(), matches(
|
||||
expect(error!.toStringDeep(), matches(
|
||||
// RegExp matcher is required here due to flutter web and flutter mobile generating
|
||||
// slightly different floating point numbers
|
||||
// in Flutter web 0.0 sometimes just appears as 0. or 0
|
||||
|
||||
@@ -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:math' as math;
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
@@ -275,9 +273,6 @@ void main() {
|
||||
});
|
||||
|
||||
test('CatmullRomSpline enforces contract', () {
|
||||
expect(() {
|
||||
CatmullRomSpline(null);
|
||||
}, throwsAssertionError);
|
||||
expect(() {
|
||||
CatmullRomSpline(const <Offset>[]);
|
||||
}, throwsAssertionError);
|
||||
@@ -327,9 +322,6 @@ void main() {
|
||||
});
|
||||
|
||||
test('CatmullRomSpline enforces contract when precomputed', () {
|
||||
expect(() {
|
||||
CatmullRomSpline.precompute(null);
|
||||
}, throwsAssertionError);
|
||||
expect(() {
|
||||
CatmullRomSpline.precompute(const <Offset>[]);
|
||||
}, throwsAssertionError);
|
||||
@@ -395,9 +387,6 @@ void main() {
|
||||
});
|
||||
|
||||
test('CatmullRomCurve enforces contract', () {
|
||||
expect(() {
|
||||
CatmullRomCurve(null);
|
||||
}, throwsAssertionError);
|
||||
expect(() {
|
||||
CatmullRomCurve(const <Offset>[]);
|
||||
}, throwsAssertionError);
|
||||
@@ -517,9 +506,6 @@ void main() {
|
||||
});
|
||||
|
||||
test('CatmullRomCurve enforces contract when precomputed', () {
|
||||
expect(() {
|
||||
CatmullRomCurve.precompute(null);
|
||||
}, throwsAssertionError);
|
||||
expect(() {
|
||||
CatmullRomCurve.precompute(const <Offset>[]);
|
||||
}, throwsAssertionError);
|
||||
|
||||
@@ -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:flutter_test/flutter_test.dart';
|
||||
import 'package:flutter/animation.dart';
|
||||
import 'package:flutter/scheduler.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 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:flutter/animation.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
@@ -11,7 +9,7 @@ import 'package:flutter/widgets.dart';
|
||||
void main() {
|
||||
setUp(() {
|
||||
WidgetsFlutterBinding.ensureInitialized();
|
||||
WidgetsBinding.instance.resetEpoch();
|
||||
WidgetsBinding.instance!.resetEpoch();
|
||||
});
|
||||
|
||||
test('AnimationController with mutating listener', () {
|
||||
@@ -92,7 +90,7 @@ void main() {
|
||||
final VoidCallback listener1 = () { log.add('listener1'); };
|
||||
final VoidCallback badListener = () {
|
||||
log.add('badListener');
|
||||
throw null;
|
||||
throw ArgumentError();
|
||||
};
|
||||
final VoidCallback listener2 = () { log.add('listener2'); };
|
||||
|
||||
@@ -101,7 +99,7 @@ void main() {
|
||||
controller.addListener(listener2);
|
||||
controller.value = 0.2;
|
||||
expect(log, <String>['listener1', 'badListener', 'listener2']);
|
||||
expect(tester.takeException(), isNullThrownError);
|
||||
expect(tester.takeException(), isArgumentError);
|
||||
log.clear();
|
||||
});
|
||||
|
||||
@@ -115,7 +113,7 @@ void main() {
|
||||
final AnimationStatusListener listener1 = (AnimationStatus status) { log.add('listener1'); };
|
||||
final AnimationStatusListener badListener = (AnimationStatus status) {
|
||||
log.add('badListener');
|
||||
throw null;
|
||||
throw ArgumentError();
|
||||
};
|
||||
final AnimationStatusListener listener2 = (AnimationStatus status) { log.add('listener2'); };
|
||||
|
||||
@@ -124,7 +122,7 @@ void main() {
|
||||
controller.addStatusListener(listener2);
|
||||
controller.forward();
|
||||
expect(log, <String>['listener1', 'badListener', 'listener2']);
|
||||
expect(tester.takeException(), isNullThrownError);
|
||||
expect(tester.takeException(), isArgumentError);
|
||||
log.clear();
|
||||
controller.dispose();
|
||||
});
|
||||
|
||||
@@ -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:flutter_test/flutter_test.dart';
|
||||
import 'package:flutter/animation.dart';
|
||||
import 'package:flutter/widgets.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 'package:flutter/foundation.dart';
|
||||
import '../flutter_test_alternative.dart';
|
||||
|
||||
@@ -442,7 +440,7 @@ void main() {
|
||||
],
|
||||
replacement: 'test',
|
||||
);
|
||||
final List<String> reasons = List<String>(2);
|
||||
final List<String?> reasons = List<String?>.filled(2, null);
|
||||
filter.filter(
|
||||
const <StackFrame>[
|
||||
StackFrame(className: 'TestClass', method: 'test1', packageScheme: 'package', package: 'test', packagePath: 'blah.dart', line: 1, column: 1, number: 0, source: ''),
|
||||
@@ -450,6 +448,6 @@ void main() {
|
||||
],
|
||||
reasons,
|
||||
);
|
||||
expect(reasons, List<String>(2));
|
||||
expect(reasons, List<String?>.filled(2, 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
|
||||
|
||||
@TestOn('!chrome')
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
|
||||
@@ -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 'package:flutter/foundation.dart';
|
||||
|
||||
import '../flutter_test_alternative.dart';
|
||||
|
||||
int yieldCount;
|
||||
int yieldCount = 0;
|
||||
|
||||
Iterable<int> range(int start, int end) sync* {
|
||||
assert(yieldCount == 0);
|
||||
|
||||
@@ -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:flutter/foundation.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 'package:flutter/foundation.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
@@ -41,7 +39,7 @@ void main() {
|
||||
final VoidCallback listener2 = () { log.add('listener2'); };
|
||||
final VoidCallback badListener = () {
|
||||
log.add('badListener');
|
||||
throw null;
|
||||
throw ArgumentError();
|
||||
};
|
||||
|
||||
final TestNotifier test = TestNotifier();
|
||||
@@ -95,7 +93,7 @@ void main() {
|
||||
test.addListener(badListener);
|
||||
test.notify();
|
||||
expect(log, <String>['listener', 'listener2', 'listener1', 'badListener']);
|
||||
expect(tester.takeException(), isNullThrownError);
|
||||
expect(tester.takeException(), isArgumentError);
|
||||
log.clear();
|
||||
|
||||
test.addListener(listener1);
|
||||
@@ -105,7 +103,7 @@ void main() {
|
||||
test.addListener(listener2);
|
||||
test.notify();
|
||||
expect(log, <String>['badListener', 'listener1', 'listener2']);
|
||||
expect(tester.takeException(), isNullThrownError);
|
||||
expect(tester.takeException(), isArgumentError);
|
||||
log.clear();
|
||||
});
|
||||
|
||||
@@ -238,7 +236,7 @@ void main() {
|
||||
final TestNotifier source2 = TestNotifier();
|
||||
final List<String> log = <String>[];
|
||||
|
||||
final Listenable merged = Listenable.merge(<Listenable>[null, source1, null, source2, null]);
|
||||
final Listenable merged = Listenable.merge(<Listenable?>[null, source1, null, source2, null]);
|
||||
final VoidCallback listener = () { log.add('listener'); };
|
||||
|
||||
merged.addListener(listener);
|
||||
@@ -300,7 +298,7 @@ void main() {
|
||||
Listenable listenableUnderTest = Listenable.merge(<Listenable>[]);
|
||||
expect(listenableUnderTest.toString(), 'Listenable.merge([])');
|
||||
|
||||
listenableUnderTest = Listenable.merge(<Listenable>[null]);
|
||||
listenableUnderTest = Listenable.merge(<Listenable?>[null]);
|
||||
expect(listenableUnderTest.toString(), 'Listenable.merge([null])');
|
||||
|
||||
listenableUnderTest = Listenable.merge(<Listenable>[source1]);
|
||||
@@ -315,7 +313,7 @@ void main() {
|
||||
"Listenable.merge([Instance of 'TestNotifier', Instance of 'TestNotifier'])",
|
||||
);
|
||||
|
||||
listenableUnderTest = Listenable.merge(<Listenable>[null, source2]);
|
||||
listenableUnderTest = Listenable.merge(<Listenable?>[null, source2]);
|
||||
expect(
|
||||
listenableUnderTest.toString(),
|
||||
"Listenable.merge([null, Instance of 'TestNotifier'])",
|
||||
@@ -382,14 +380,14 @@ void main() {
|
||||
test('Throws FlutterError when disposed and called', () {
|
||||
final TestNotifier testNotifier = TestNotifier();
|
||||
testNotifier.dispose();
|
||||
FlutterError error;
|
||||
FlutterError? error;
|
||||
try {
|
||||
testNotifier.dispose();
|
||||
} on FlutterError catch (e) {
|
||||
error = e;
|
||||
}
|
||||
expect(error, isNotNull);
|
||||
expect(error, isFlutterError);
|
||||
expect(error!, isFlutterError);
|
||||
expect(error.toStringDeep(), equalsIgnoringHashCodes(
|
||||
'FlutterError\n'
|
||||
' A TestNotifier was used after being disposed.\n'
|
||||
|
||||
@@ -2,7 +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:math';
|
||||
|
||||
import 'package:flutter/src/foundation/collections.dart';
|
||||
@@ -64,10 +63,8 @@ void main() {
|
||||
test('MergeSortRandom', () {
|
||||
final Random random = Random();
|
||||
for (int i = 0; i < 250; i += 1) {
|
||||
final List<int> list = List<int>(i);
|
||||
for (int j = 0; j < i; j++) {
|
||||
list[j] = random.nextInt(i); // Expect some equal elements.
|
||||
}
|
||||
// Expect some equal elements.
|
||||
final List<int> list = List<int>.generate(i, (int j) => random.nextInt(i));
|
||||
mergeSort(list);
|
||||
for (int j = 1; j < i; j++) {
|
||||
expect(list[j - 1], lessThanOrEqualTo(list[j]));
|
||||
@@ -80,14 +77,12 @@ void main() {
|
||||
// larger case where the internal moving insertion sort is used
|
||||
// larger cases with multiple splittings, numbers just around a power of 2.
|
||||
for (final int size in <int>[8, 50, 511, 512, 513]) {
|
||||
final List<OrderedComparable> list = List<OrderedComparable>(size);
|
||||
// Class OC compares using id.
|
||||
// With size elements with id's in the range 0..size/4, a number of
|
||||
// collisions are guaranteed. These should be sorted so that the 'order'
|
||||
// part of the objects are still in order.
|
||||
for (int i = 0; i < size; i++) {
|
||||
list[i] = OrderedComparable(random.nextInt(size >> 2), i);
|
||||
}
|
||||
final List<OrderedComparable> list = List<OrderedComparable>.generate(
|
||||
size, (int i) => OrderedComparable(random.nextInt(size >> 2), i));
|
||||
mergeSort(list);
|
||||
OrderedComparable prev = list[0];
|
||||
for (int i = 1; i < size; i++) {
|
||||
@@ -126,10 +121,8 @@ void main() {
|
||||
test('MergeSortSpecialCases', () {
|
||||
for (final int size in <int>[511, 512, 513]) {
|
||||
// All equal.
|
||||
final List<OrderedComparable> list = List<OrderedComparable>(size);
|
||||
for (int i = 0; i < size; i++) {
|
||||
list[i] = OrderedComparable(0, i);
|
||||
}
|
||||
final List<OrderedComparable> list = List<OrderedComparable>.generate(
|
||||
size, (int i) => OrderedComparable(0, i));
|
||||
mergeSort(list);
|
||||
for (int i = 0; i < size; i++) {
|
||||
expect(list[i].order, equals(i));
|
||||
|
||||
@@ -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
|
||||
|
||||
@TestOn('!chrome')
|
||||
|
||||
import 'dart:async';
|
||||
@@ -18,7 +16,7 @@ final Uint8List chunkOne = Uint8List.fromList(<int>[0, 1, 2, 3, 4, 5]);
|
||||
final Uint8List chunkTwo = Uint8List.fromList(<int>[6, 7, 8, 9, 10]);
|
||||
void main() {
|
||||
group(consolidateHttpClientResponseBytes, () {
|
||||
MockHttpClientResponse response;
|
||||
late MockHttpClientResponse response;
|
||||
|
||||
setUp(() {
|
||||
response = MockHttpClientResponse(
|
||||
@@ -54,11 +52,11 @@ void main() {
|
||||
test('Notifies onBytesReceived for every chunk of bytes', () async {
|
||||
final int syntheticTotal = (chunkOne.length + chunkTwo.length) * 2;
|
||||
response.contentLength = syntheticTotal;
|
||||
final List<int> records = <int>[];
|
||||
final List<int?> records = <int?>[];
|
||||
await consolidateHttpClientResponseBytes(
|
||||
response,
|
||||
onBytesReceived: (int cumulative, int total) {
|
||||
records.addAll(<int>[cumulative, total]);
|
||||
onBytesReceived: (int cumulative, int? total) {
|
||||
records.addAll(<int?>[cumulative, total]);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -81,7 +79,7 @@ void main() {
|
||||
response.contentLength = -1;
|
||||
final Future<List<int>> result = consolidateHttpClientResponseBytes(
|
||||
response,
|
||||
onBytesReceived: (int cumulative, int total) {
|
||||
onBytesReceived: (int cumulative, int? total) {
|
||||
throw 'misbehaving callback';
|
||||
},
|
||||
);
|
||||
@@ -113,11 +111,11 @@ void main() {
|
||||
|
||||
test('Notifies onBytesReceived with gzipped numbers', () async {
|
||||
response.contentLength = gzipped.length;
|
||||
final List<int> records = <int>[];
|
||||
final List<int?> records = <int>[];
|
||||
await consolidateHttpClientResponseBytes(
|
||||
response,
|
||||
onBytesReceived: (int cumulative, int total) {
|
||||
records.addAll(<int>[cumulative, total]);
|
||||
onBytesReceived: (int cumulative, int? total) {
|
||||
records.addAll(<int?>[cumulative, total]);
|
||||
},
|
||||
);
|
||||
|
||||
@@ -133,15 +131,15 @@ void main() {
|
||||
final int syntheticTotal = (chunkOne.length + chunkTwo.length) * 2;
|
||||
response.compressionState = HttpClientResponseCompressionState.decompressed;
|
||||
response.contentLength = syntheticTotal;
|
||||
final List<int> records = <int>[];
|
||||
final List<int?> records = <int?>[];
|
||||
await consolidateHttpClientResponseBytes(
|
||||
response,
|
||||
onBytesReceived: (int cumulative, int total) {
|
||||
records.addAll(<int>[cumulative, total]);
|
||||
onBytesReceived: (int cumulative, int? total) {
|
||||
records.addAll(<int?>[cumulative, total]);
|
||||
},
|
||||
);
|
||||
|
||||
expect(records, <int>[
|
||||
expect(records, <int?>[
|
||||
gzippedChunkOne.length,
|
||||
null,
|
||||
gzipped.length,
|
||||
@@ -153,7 +151,7 @@ void main() {
|
||||
}
|
||||
|
||||
class MockHttpClientResponse extends Fake implements HttpClientResponse {
|
||||
MockHttpClientResponse({this.error, this.chunkOne, this.chunkTwo});
|
||||
MockHttpClientResponse({this.error, this.chunkOne = const <int>[], this.chunkTwo = const <int>[]});
|
||||
|
||||
final dynamic error;
|
||||
final List<int> chunkOne;
|
||||
@@ -166,10 +164,10 @@ class MockHttpClientResponse extends Fake implements HttpClientResponse {
|
||||
HttpClientResponseCompressionState compressionState = HttpClientResponseCompressionState.notCompressed;
|
||||
|
||||
@override
|
||||
StreamSubscription<List<int>> listen(void Function(List<int> event) onData, {Function onError, void Function() onDone, bool cancelOnError}) {
|
||||
StreamSubscription<List<int>> listen(void Function(List<int> event)? onData, {Function? onError, void Function()? onDone, bool? cancelOnError}) {
|
||||
if (error != null) {
|
||||
return Stream<List<int>>.fromFuture(
|
||||
Future<List<int>>.error(error)).listen(
|
||||
Future<List<int>>.error(error as Object)).listen(
|
||||
onData,
|
||||
onDone: onDone,
|
||||
onError: onError,
|
||||
|
||||
@@ -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
|
||||
|
||||
@TestOn('!chrome') // This test is not intended to run on the web.
|
||||
import 'package:flutter/foundation.dart';
|
||||
import '../flutter_test_alternative.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 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
class X {}
|
||||
@@ -11,7 +9,7 @@ class X {}
|
||||
class Y extends X {}
|
||||
|
||||
class A<U extends X> {
|
||||
U u;
|
||||
U? u;
|
||||
}
|
||||
|
||||
void main() {
|
||||
|
||||
@@ -2,21 +2,19 @@
|
||||
// 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/foundation.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
group('debugInstrumentAction', () {
|
||||
DebugPrintCallback originalDebugPrintCallback;
|
||||
StringBuffer printBuffer;
|
||||
late DebugPrintCallback originalDebugPrintCallback;
|
||||
late StringBuffer printBuffer;
|
||||
|
||||
setUp(() {
|
||||
debugInstrumentationEnabled = true;
|
||||
printBuffer = StringBuffer();
|
||||
originalDebugPrintCallback = debugPrint;
|
||||
debugPrint = (String message, { int wrapWidth }) {
|
||||
debugPrint = (String? message, { int? wrapWidth }) {
|
||||
printBuffer.writeln(message);
|
||||
};
|
||||
});
|
||||
|
||||
@@ -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:flutter/foundation.dart';
|
||||
import 'package:flutter_test/flutter_test.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 'package:flutter/foundation.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
import 'package:flutter/widgets.dart';
|
||||
@@ -13,7 +11,7 @@ void main() {
|
||||
test('Element diagnostics json includes widgetRuntimeType', () async {
|
||||
final Element element = _TestElement();
|
||||
|
||||
final Map<String, Object> json = element.toDiagnosticsNode().toJsonMap(const DiagnosticsSerializationDelegate());
|
||||
final Map<String, Object?> json = element.toDiagnosticsNode().toJsonMap(const DiagnosticsSerializationDelegate());
|
||||
expect(json['widgetRuntimeType'], 'Placeholder');
|
||||
expect(json['stateful'], isFalse);
|
||||
});
|
||||
@@ -21,7 +19,7 @@ void main() {
|
||||
test('StatefulElement diagnostics are stateful', () {
|
||||
final Element element = StatefulElement(const Tooltip(message: 'foo'));
|
||||
|
||||
final Map<String, Object> json = element.toDiagnosticsNode().toJsonMap(const DiagnosticsSerializationDelegate());
|
||||
final Map<String, Object?> json = element.toDiagnosticsNode().toJsonMap(const DiagnosticsSerializationDelegate());
|
||||
expect(json['widgetRuntimeType'], 'Tooltip');
|
||||
expect(json['stateful'], isTrue);
|
||||
});
|
||||
@@ -70,13 +68,13 @@ void main() {
|
||||
);
|
||||
|
||||
test('default', () {
|
||||
final Map<String, Object> result = testTree.toDiagnosticsNode().toJsonMap(const DiagnosticsSerializationDelegate());
|
||||
final Map<String, Object?> result = testTree.toDiagnosticsNode().toJsonMap(const DiagnosticsSerializationDelegate());
|
||||
expect(result.containsKey('properties'), isFalse);
|
||||
expect(result.containsKey('children'), isFalse);
|
||||
});
|
||||
|
||||
test('subtreeDepth 1', () {
|
||||
final Map<String, Object> result = testTree.toDiagnosticsNode().toJsonMap(const DiagnosticsSerializationDelegate(subtreeDepth: 1));
|
||||
final Map<String, Object?> result = testTree.toDiagnosticsNode().toJsonMap(const DiagnosticsSerializationDelegate(subtreeDepth: 1));
|
||||
expect(result.containsKey('properties'), isFalse);
|
||||
final List<Map<String, Object>> children = result['children'] as List<Map<String, Object>>;
|
||||
expect(children[0].containsKey('children'), isFalse);
|
||||
@@ -85,7 +83,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('subtreeDepth 5', () {
|
||||
final Map<String, Object> result = testTree.toDiagnosticsNode().toJsonMap(const DiagnosticsSerializationDelegate(subtreeDepth: 5));
|
||||
final Map<String, Object?> result = testTree.toDiagnosticsNode().toJsonMap(const DiagnosticsSerializationDelegate(subtreeDepth: 5));
|
||||
expect(result.containsKey('properties'), isFalse);
|
||||
final List<Map<String, Object>> children = result['children'] as List<Map<String, Object>>;
|
||||
expect(children[0]['children'], hasLength(0));
|
||||
@@ -94,13 +92,13 @@ void main() {
|
||||
});
|
||||
|
||||
test('includeProperties', () {
|
||||
final Map<String, Object> result = testTree.toDiagnosticsNode().toJsonMap(const DiagnosticsSerializationDelegate(includeProperties: true));
|
||||
final Map<String, Object?> result = testTree.toDiagnosticsNode().toJsonMap(const DiagnosticsSerializationDelegate(includeProperties: true));
|
||||
expect(result.containsKey('children'), isFalse);
|
||||
expect(result['properties'], hasLength(7));
|
||||
});
|
||||
|
||||
test('includeProperties with subtreedepth 1', () {
|
||||
final Map<String, Object> result = testTree.toDiagnosticsNode().toJsonMap(const DiagnosticsSerializationDelegate(
|
||||
final Map<String, Object?> result = testTree.toDiagnosticsNode().toJsonMap(const DiagnosticsSerializationDelegate(
|
||||
includeProperties: true,
|
||||
subtreeDepth: 1,
|
||||
));
|
||||
@@ -113,7 +111,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('additionalNodeProperties', () {
|
||||
final Map<String, Object> result = testTree.toDiagnosticsNode().toJsonMap(const TestDiagnosticsSerializationDelegate(
|
||||
final Map<String, Object?> result = testTree.toDiagnosticsNode().toJsonMap(const TestDiagnosticsSerializationDelegate(
|
||||
includeProperties: true,
|
||||
subtreeDepth: 1,
|
||||
additionalNodePropertiesMap: <String, Object>{
|
||||
@@ -131,7 +129,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('filterProperties - sublist', () {
|
||||
final Map<String, Object> result = testTree.toDiagnosticsNode().toJsonMap(TestDiagnosticsSerializationDelegate(
|
||||
final Map<String, Object?> result = testTree.toDiagnosticsNode().toJsonMap(TestDiagnosticsSerializationDelegate(
|
||||
includeProperties: true,
|
||||
propertyFilter: (List<DiagnosticsNode> nodes, DiagnosticsNode owner) {
|
||||
return nodes.whereType<StringProperty>().toList();
|
||||
@@ -144,7 +142,7 @@ void main() {
|
||||
|
||||
test('filterProperties - replace', () {
|
||||
bool replaced = false;
|
||||
final Map<String, Object> result = testTree.toDiagnosticsNode().toJsonMap(TestDiagnosticsSerializationDelegate(
|
||||
final Map<String, Object?> result = testTree.toDiagnosticsNode().toJsonMap(TestDiagnosticsSerializationDelegate(
|
||||
includeProperties: true,
|
||||
propertyFilter: (List<DiagnosticsNode> nodes, DiagnosticsNode owner) {
|
||||
if (replaced) {
|
||||
@@ -162,7 +160,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('filterChildren - sublist', () {
|
||||
final Map<String, Object> result = testTree.toDiagnosticsNode().toJsonMap(TestDiagnosticsSerializationDelegate(
|
||||
final Map<String, Object?> result = testTree.toDiagnosticsNode().toJsonMap(TestDiagnosticsSerializationDelegate(
|
||||
subtreeDepth: 1,
|
||||
childFilter: (List<DiagnosticsNode> nodes, DiagnosticsNode owner) {
|
||||
return nodes.where((DiagnosticsNode node) => node.getProperties().isEmpty).toList();
|
||||
@@ -173,7 +171,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('filterChildren - replace', () {
|
||||
final Map<String, Object> result = testTree.toDiagnosticsNode().toJsonMap(TestDiagnosticsSerializationDelegate(
|
||||
final Map<String, Object?> result = testTree.toDiagnosticsNode().toJsonMap(TestDiagnosticsSerializationDelegate(
|
||||
subtreeDepth: 1,
|
||||
childFilter: (List<DiagnosticsNode> nodes, DiagnosticsNode owner) {
|
||||
return nodes.expand((DiagnosticsNode node) => node.getChildren()).toList();
|
||||
@@ -185,10 +183,10 @@ void main() {
|
||||
});
|
||||
|
||||
test('nodeTruncator', () {
|
||||
final Map<String, Object> result = testTree.toDiagnosticsNode().toJsonMap(TestDiagnosticsSerializationDelegate(
|
||||
final Map<String, Object?> result = testTree.toDiagnosticsNode().toJsonMap(TestDiagnosticsSerializationDelegate(
|
||||
subtreeDepth: 5,
|
||||
includeProperties: true,
|
||||
nodeTruncator: (List<DiagnosticsNode> nodes, DiagnosticsNode owner) {
|
||||
nodeTruncator: (List<DiagnosticsNode> nodes, DiagnosticsNode? owner) {
|
||||
return nodes.take(2).toList();
|
||||
},
|
||||
));
|
||||
@@ -202,7 +200,7 @@ void main() {
|
||||
});
|
||||
|
||||
test('delegateForAddingNodes', () {
|
||||
final Map<String, Object> result = testTree.toDiagnosticsNode().toJsonMap(TestDiagnosticsSerializationDelegate(
|
||||
final Map<String, Object?> result = testTree.toDiagnosticsNode().toJsonMap(TestDiagnosticsSerializationDelegate(
|
||||
subtreeDepth: 5,
|
||||
includeProperties: true,
|
||||
nodeDelegator: (DiagnosticsNode node, DiagnosticsSerializationDelegate delegate) {
|
||||
@@ -234,7 +232,7 @@ class _TestElement extends Element {
|
||||
|
||||
class TestTree extends Object with DiagnosticableTreeMixin {
|
||||
TestTree({
|
||||
this.name,
|
||||
this.name = '',
|
||||
this.style,
|
||||
this.children = const <TestTree>[],
|
||||
this.properties = const <DiagnosticsNode>[],
|
||||
@@ -243,7 +241,7 @@ class TestTree extends Object with DiagnosticableTreeMixin {
|
||||
final String name;
|
||||
final List<TestTree> children;
|
||||
final List<DiagnosticsNode> properties;
|
||||
final DiagnosticsTreeStyle style;
|
||||
final DiagnosticsTreeStyle? style;
|
||||
|
||||
@override
|
||||
List<DiagnosticsNode> debugDescribeChildren() => <DiagnosticsNode>[
|
||||
@@ -258,12 +256,16 @@ class TestTree extends Object with DiagnosticableTreeMixin {
|
||||
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
|
||||
super.debugFillProperties(properties);
|
||||
if (style != null)
|
||||
properties.defaultDiagnosticsTreeStyle = style;
|
||||
properties.defaultDiagnosticsTreeStyle = style!;
|
||||
|
||||
this.properties.forEach(properties.add);
|
||||
}
|
||||
}
|
||||
|
||||
typedef NodeDelegator = DiagnosticsSerializationDelegate Function(DiagnosticsNode node, TestDiagnosticsSerializationDelegate delegate);
|
||||
typedef NodeTruncator = List<DiagnosticsNode> Function(List<DiagnosticsNode> nodes, DiagnosticsNode? owner);
|
||||
typedef NodeFilter = List<DiagnosticsNode> Function(List<DiagnosticsNode> nodes, DiagnosticsNode owner);
|
||||
|
||||
class TestDiagnosticsSerializationDelegate implements DiagnosticsSerializationDelegate {
|
||||
const TestDiagnosticsSerializationDelegate({
|
||||
this.includeProperties = false,
|
||||
@@ -276,10 +278,10 @@ class TestDiagnosticsSerializationDelegate implements DiagnosticsSerializationDe
|
||||
});
|
||||
|
||||
final Map<String, Object> additionalNodePropertiesMap;
|
||||
final List<DiagnosticsNode> Function(List<DiagnosticsNode> nodes, DiagnosticsNode owner) childFilter;
|
||||
final List<DiagnosticsNode> Function(List<DiagnosticsNode> nodes, DiagnosticsNode owner) propertyFilter;
|
||||
final List<DiagnosticsNode> Function(List<DiagnosticsNode> nodes, DiagnosticsNode owner) nodeTruncator;
|
||||
final DiagnosticsSerializationDelegate Function(DiagnosticsNode node, TestDiagnosticsSerializationDelegate delegate) nodeDelegator;
|
||||
final NodeFilter? childFilter;
|
||||
final NodeFilter? propertyFilter;
|
||||
final NodeTruncator? nodeTruncator;
|
||||
final NodeDelegator? nodeDelegator;
|
||||
|
||||
@override
|
||||
Map<String, Object> additionalNodeProperties(DiagnosticsNode node) {
|
||||
@@ -289,7 +291,7 @@ class TestDiagnosticsSerializationDelegate implements DiagnosticsSerializationDe
|
||||
@override
|
||||
DiagnosticsSerializationDelegate delegateForNode(DiagnosticsNode node) {
|
||||
if (nodeDelegator != null) {
|
||||
return nodeDelegator(node, this);
|
||||
return nodeDelegator!(node, this);
|
||||
}
|
||||
return subtreeDepth > 0 ? copyWith(subtreeDepth: subtreeDepth - 1) : this;
|
||||
}
|
||||
@@ -299,12 +301,12 @@ class TestDiagnosticsSerializationDelegate implements DiagnosticsSerializationDe
|
||||
|
||||
@override
|
||||
List<DiagnosticsNode> filterChildren(List<DiagnosticsNode> nodes, DiagnosticsNode owner) {
|
||||
return childFilter != null ? childFilter(nodes, owner) : nodes;
|
||||
return childFilter?.call(nodes, owner) ?? nodes;
|
||||
}
|
||||
|
||||
@override
|
||||
List<DiagnosticsNode> filterProperties(List<DiagnosticsNode> nodes, DiagnosticsNode owner) {
|
||||
return propertyFilter != null ? propertyFilter(nodes, owner) : nodes;
|
||||
return propertyFilter?.call(nodes, owner) ?? nodes;
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -314,12 +316,12 @@ class TestDiagnosticsSerializationDelegate implements DiagnosticsSerializationDe
|
||||
final int subtreeDepth;
|
||||
|
||||
@override
|
||||
List<DiagnosticsNode> truncateNodesList(List<DiagnosticsNode> nodes, DiagnosticsNode owner) {
|
||||
return nodeTruncator != null ? nodeTruncator(nodes, owner) : nodes;
|
||||
List<DiagnosticsNode> truncateNodesList(List<DiagnosticsNode> nodes, DiagnosticsNode? owner) {
|
||||
return nodeTruncator?.call(nodes, owner) ?? nodes;
|
||||
}
|
||||
|
||||
@override
|
||||
DiagnosticsSerializationDelegate copyWith({int subtreeDepth, bool includeProperties}) {
|
||||
DiagnosticsSerializationDelegate copyWith({int? subtreeDepth, bool? includeProperties}) {
|
||||
return TestDiagnosticsSerializationDelegate(
|
||||
includeProperties: includeProperties ?? this.includeProperties,
|
||||
subtreeDepth: subtreeDepth ?? this.subtreeDepth,
|
||||
|
||||
@@ -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:convert';
|
||||
import 'dart:ui';
|
||||
|
||||
@@ -12,7 +10,7 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
class TestTree extends Object with DiagnosticableTreeMixin {
|
||||
TestTree({
|
||||
this.name,
|
||||
this.name = '',
|
||||
this.style,
|
||||
this.children = const <TestTree>[],
|
||||
this.properties = const <DiagnosticsNode>[],
|
||||
@@ -21,7 +19,7 @@ class TestTree extends Object with DiagnosticableTreeMixin {
|
||||
final String name;
|
||||
final List<TestTree> children;
|
||||
final List<DiagnosticsNode> properties;
|
||||
final DiagnosticsTreeStyle style;
|
||||
final DiagnosticsTreeStyle? style;
|
||||
|
||||
@override
|
||||
List<DiagnosticsNode> debugDescribeChildren() => <DiagnosticsNode>[
|
||||
@@ -36,8 +34,7 @@ class TestTree extends Object with DiagnosticableTreeMixin {
|
||||
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
|
||||
super.debugFillProperties(properties);
|
||||
if (style != null)
|
||||
properties.defaultDiagnosticsTreeStyle = style;
|
||||
|
||||
properties.defaultDiagnosticsTreeStyle = style!;
|
||||
this.properties.forEach(properties.add);
|
||||
}
|
||||
}
|
||||
@@ -65,7 +62,7 @@ void validateNodeJsonSerializationHelper(Map<String, Object> json, DiagnosticsNo
|
||||
expect(json['level'] ?? describeEnum(DiagnosticLevel.info), equals(describeEnum(node.level)));
|
||||
expect(json['showName'] ?? true, equals(node.showName));
|
||||
expect(json['emptyBodyDescription'], equals(node.emptyBodyDescription));
|
||||
expect(json['style'] ?? describeEnum(DiagnosticsTreeStyle.sparse), equals(describeEnum(node.style)));
|
||||
expect(json['style'] ?? describeEnum(DiagnosticsTreeStyle.sparse), equals(describeEnum(node.style!)));
|
||||
expect(json['type'], equals(node.runtimeType.toString()));
|
||||
expect(json['hasChildren'] ?? false, equals(node.getChildren().isNotEmpty));
|
||||
}
|
||||
@@ -122,13 +119,13 @@ void validateObjectFlagPropertyJsonSerialization(ObjectFlagProperty<Object> prop
|
||||
validatePropertyJsonSerializationHelper(json, property);
|
||||
}
|
||||
|
||||
void validateIterableFlagsPropertyJsonSerialization(FlagsSummary<Object> property) {
|
||||
void validateIterableFlagsPropertyJsonSerialization(FlagsSummary<Object?> property) {
|
||||
final Map<String, Object> json = simulateJsonSerialization(property);
|
||||
if (property.value.isNotEmpty) {
|
||||
expect(json['values'], equals(
|
||||
property.value.entries
|
||||
.where((MapEntry<String, Object> entry) => entry.value != null)
|
||||
.map((MapEntry<String, Object> entry) => entry.key).toList(),
|
||||
.where((MapEntry<String, Object?> entry) => entry.value != null)
|
||||
.map((MapEntry<String, Object?> entry) => entry.key).toList(),
|
||||
));
|
||||
} else {
|
||||
expect(json.containsKey('values'), isFalse);
|
||||
@@ -141,7 +138,7 @@ void validateIterablePropertyJsonSerialization(IterableProperty<Object> property
|
||||
final Map<String, Object> json = simulateJsonSerialization(property);
|
||||
if (property.value != null) {
|
||||
final List<Object> valuesJson = json['values'] as List<Object>;
|
||||
final List<String> expectedValues = property.value.map<String>((Object value) => value.toString()).toList();
|
||||
final List<String> expectedValues = property.value!.map<String>((Object value) => value.toString()).toList();
|
||||
expect(listEquals(valuesJson, expectedValues), isTrue);
|
||||
} else {
|
||||
expect(json.containsKey('values'), isFalse);
|
||||
@@ -194,8 +191,8 @@ void main() {
|
||||
test('TreeDiagnosticsMixin control test', () async {
|
||||
void goldenStyleTest(
|
||||
String description, {
|
||||
DiagnosticsTreeStyle style,
|
||||
DiagnosticsTreeStyle lastChildStyle,
|
||||
DiagnosticsTreeStyle? style,
|
||||
DiagnosticsTreeStyle? lastChildStyle,
|
||||
String golden = '',
|
||||
}) {
|
||||
final TestTree tree = TestTree(children: <TestTree>[
|
||||
@@ -367,11 +364,11 @@ void main() {
|
||||
test('TreeDiagnosticsMixin tree with properties test', () async {
|
||||
void goldenStyleTest(
|
||||
String description, {
|
||||
String name,
|
||||
DiagnosticsTreeStyle style,
|
||||
DiagnosticsTreeStyle lastChildStyle,
|
||||
String? name,
|
||||
DiagnosticsTreeStyle? style,
|
||||
DiagnosticsTreeStyle? lastChildStyle,
|
||||
DiagnosticsTreeStyle propertyStyle = DiagnosticsTreeStyle.singleLine,
|
||||
@required String golden,
|
||||
required String golden,
|
||||
}) {
|
||||
final TestTree tree = TestTree(
|
||||
properties: <DiagnosticsNode>[
|
||||
@@ -1696,7 +1693,7 @@ void main() {
|
||||
// Partially empty property
|
||||
{
|
||||
final Function onClick = () { };
|
||||
final Map<String, Function> value = <String, Function>{
|
||||
final Map<String, Function?> value = <String, Function?>{
|
||||
'move': null,
|
||||
'click': onClick,
|
||||
};
|
||||
@@ -1711,7 +1708,7 @@ void main() {
|
||||
|
||||
// Empty property (without ifEmpty)
|
||||
{
|
||||
final Map<String, Function> value = <String, Function>{
|
||||
final Map<String, Function?> value = <String, Function?>{
|
||||
'enter': null,
|
||||
};
|
||||
final FlagsSummary<Function> flags = FlagsSummary<Function>(
|
||||
@@ -1724,7 +1721,7 @@ void main() {
|
||||
|
||||
// Empty property (without ifEmpty)
|
||||
{
|
||||
final Map<String, Function> value = <String, Function>{
|
||||
final Map<String, Function?> value = <String, Function?>{
|
||||
'enter': null,
|
||||
};
|
||||
final FlagsSummary<Function> flags = FlagsSummary<Function>(
|
||||
@@ -1922,14 +1919,14 @@ void main() {
|
||||
expect(messageProperty.name, equals('diagnostics'));
|
||||
expect(messageProperty.value, isNull);
|
||||
expect(messageProperty.showName, isTrue);
|
||||
validatePropertyJsonSerialization(messageProperty as MessageProperty);
|
||||
validatePropertyJsonSerialization(messageProperty as DiagnosticsProperty<Object>);
|
||||
});
|
||||
|
||||
test('error message style wrap test', () {
|
||||
// This tests wrapping of properties with styles typical for error messages.
|
||||
DiagnosticsNode createTreeWithWrappingNodes({
|
||||
DiagnosticsTreeStyle rootStyle,
|
||||
DiagnosticsTreeStyle propertyStyle,
|
||||
DiagnosticsTreeStyle? rootStyle,
|
||||
required DiagnosticsTreeStyle propertyStyle,
|
||||
}) {
|
||||
return TestTree(
|
||||
name: 'Test tree',
|
||||
|
||||
@@ -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:flutter/foundation.dart';
|
||||
import '../flutter_test_alternative.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
|
||||
|
||||
@TestOn('!chrome') // web has different stack traces
|
||||
|
||||
import 'package:flutter/foundation.dart';
|
||||
@@ -41,13 +39,13 @@ Future<StackTrace> getSampleStack() async {
|
||||
}
|
||||
|
||||
Future<void> main() async {
|
||||
final List<String> console = <String>[];
|
||||
final List<String?> console = <String?>[];
|
||||
|
||||
final StackTrace sampleStack = await getSampleStack();
|
||||
|
||||
setUp(() async {
|
||||
expect(debugPrint, equals(debugPrintThrottled));
|
||||
debugPrint = (String message, { int wrapWidth }) {
|
||||
debugPrint = (String? message, { int? wrapWidth }) {
|
||||
console.add(message);
|
||||
};
|
||||
});
|
||||
@@ -160,7 +158,7 @@ Future<void> main() async {
|
||||
|
||||
test('Error reporting - NoSuchMethodError', () async {
|
||||
expect(console, isEmpty);
|
||||
final dynamic exception = NoSuchMethodError.withInvocation(5,
|
||||
final Object exception = NoSuchMethodError.withInvocation(5,
|
||||
Invocation.method(#foo, <dynamic>[2, 4]));
|
||||
|
||||
FlutterError.dumpErrorToConsole(FlutterErrorDetails(
|
||||
|
||||
@@ -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
|
||||
|
||||
@TestOn('!chrome') // isolates not supported on the web.
|
||||
|
||||
import 'package:flutter/foundation.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 'package:flutter/foundation.dart';
|
||||
import '../flutter_test_alternative.dart';
|
||||
|
||||
@@ -11,7 +9,7 @@ void main() {
|
||||
test('LicenseEntryWithLineBreaks - most cases', () {
|
||||
// There's some trailing spaces in this string.
|
||||
// To avoid IDEs stripping them, I've escaped them as \u0020.
|
||||
final List<LicenseParagraph> paragraphs = const LicenseEntryWithLineBreaks(null, '''
|
||||
final List<LicenseParagraph> paragraphs = const LicenseEntryWithLineBreaks(<String>[], '''
|
||||
A
|
||||
A
|
||||
A
|
||||
@@ -159,17 +157,17 @@ S
|
||||
});
|
||||
|
||||
test('LicenseEntryWithLineBreaks - leading and trailing whitespace', () {
|
||||
expect(const LicenseEntryWithLineBreaks(null, ' \n\n ').paragraphs.toList(), isEmpty);
|
||||
expect(const LicenseEntryWithLineBreaks(null, ' \r\n\r\n ').paragraphs.toList(), isEmpty);
|
||||
expect(const LicenseEntryWithLineBreaks(<String>[], ' \n\n ').paragraphs.toList(), isEmpty);
|
||||
expect(const LicenseEntryWithLineBreaks(<String>[], ' \r\n\r\n ').paragraphs.toList(), isEmpty);
|
||||
|
||||
List<LicenseParagraph> paragraphs;
|
||||
|
||||
paragraphs = const LicenseEntryWithLineBreaks(null, ' \nA\n ').paragraphs.toList();
|
||||
paragraphs = const LicenseEntryWithLineBreaks(<String>[], ' \nA\n ').paragraphs.toList();
|
||||
expect(paragraphs[0].text, 'A');
|
||||
expect(paragraphs[0].indent, 0);
|
||||
expect(paragraphs, hasLength(1));
|
||||
|
||||
paragraphs = const LicenseEntryWithLineBreaks(null, '\n\n\nA\n\n\n').paragraphs.toList();
|
||||
paragraphs = const LicenseEntryWithLineBreaks(<String>[], '\n\n\nA\n\n\n').paragraphs.toList();
|
||||
expect(paragraphs[0].text, 'A');
|
||||
expect(paragraphs[0].indent, 0);
|
||||
expect(paragraphs, hasLength(1));
|
||||
@@ -178,12 +176,12 @@ S
|
||||
test('LicenseRegistry', () async {
|
||||
expect(await LicenseRegistry.licenses.toList(), isEmpty);
|
||||
LicenseRegistry.addLicense(() async* {
|
||||
yield const LicenseEntryWithLineBreaks(null, 'A');
|
||||
yield const LicenseEntryWithLineBreaks(null, 'B');
|
||||
yield const LicenseEntryWithLineBreaks(<String>[], 'A');
|
||||
yield const LicenseEntryWithLineBreaks(<String>[], 'B');
|
||||
});
|
||||
LicenseRegistry.addLicense(() async* {
|
||||
yield const LicenseEntryWithLineBreaks(null, 'C');
|
||||
yield const LicenseEntryWithLineBreaks(null, 'D');
|
||||
yield const LicenseEntryWithLineBreaks(<String>[], 'C');
|
||||
yield const LicenseEntryWithLineBreaks(<String>[], 'D');
|
||||
});
|
||||
expect(await LicenseRegistry.licenses.toList(), hasLength(4));
|
||||
final List<LicenseEntry> licenses = await LicenseRegistry.licenses.toList();
|
||||
|
||||
@@ -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:flutter/foundation.dart';
|
||||
import 'package:flutter_test/flutter_test.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:io' show Platform;
|
||||
|
||||
/// Returns [Platform.pathSeparator], suitably escaped so as to be usable in a
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.10
|
||||
import 'package:flutter/foundation.dart';
|
||||
import 'package:fake_async/fake_async.dart';
|
||||
import '../flutter_test_alternative.dart';
|
||||
|
||||
@@ -2,14 +2,12 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
// @dart = 2.8
|
||||
|
||||
@TestOn('!chrome')
|
||||
import 'package:flutter/foundation.dart';
|
||||
import '../flutter_test_alternative.dart';
|
||||
|
||||
class TestFoundationFlutterBinding extends BindingBase {
|
||||
bool wasLocked;
|
||||
bool? wasLocked;
|
||||
|
||||
@override
|
||||
Future<void> performReassemble() async {
|
||||
@@ -21,8 +19,6 @@ class TestFoundationFlutterBinding extends BindingBase {
|
||||
TestFoundationFlutterBinding binding = TestFoundationFlutterBinding();
|
||||
|
||||
void main() {
|
||||
binding ??= TestFoundationFlutterBinding();
|
||||
|
||||
test('Pointer events are locked during reassemble', () async {
|
||||
await binding.reassembleApplication();
|
||||
expect(binding.wasLocked, isTrue);
|
||||
|
||||
@@ -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
|
||||
|
||||
@TestOn('!chrome') // web does not support certain 64bit behavior
|
||||
|
||||
import 'dart:typed_data';
|
||||
|
||||
@@ -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:typed_data';
|
||||
@@ -31,9 +29,10 @@ class TestServiceExtensionsBinding extends BindingBase
|
||||
final Map<String, List<Map<String, dynamic>>> eventsDispatched = <String, List<Map<String, dynamic>>>{};
|
||||
|
||||
@override
|
||||
@protected
|
||||
void registerServiceExtension({
|
||||
@required String name,
|
||||
@required ServiceExtensionCallback callback,
|
||||
required String name,
|
||||
required ServiceExtensionCallback callback,
|
||||
}) {
|
||||
expect(extensions.containsKey(name), isFalse);
|
||||
extensions[name] = callback;
|
||||
@@ -55,7 +54,7 @@ class TestServiceExtensionsBinding extends BindingBase
|
||||
|
||||
Future<Map<String, dynamic>> testExtension(String name, Map<String, String> arguments) {
|
||||
expect(extensions.containsKey(name), isTrue);
|
||||
return extensions[name](arguments);
|
||||
return extensions[name]!(arguments);
|
||||
}
|
||||
|
||||
int reassembled = 0;
|
||||
@@ -75,13 +74,10 @@ class TestServiceExtensionsBinding extends BindingBase
|
||||
}
|
||||
Future<void> doFrame() async {
|
||||
frameScheduled = false;
|
||||
if (ui.window.onBeginFrame != null)
|
||||
ui.window.onBeginFrame(Duration.zero);
|
||||
ui.window.onBeginFrame?.call(Duration.zero);
|
||||
await flushMicrotasks();
|
||||
if (ui.window.onDrawFrame != null)
|
||||
ui.window.onDrawFrame();
|
||||
if (ui.window.onReportTimings != null)
|
||||
ui.window.onReportTimings(<ui.FrameTiming>[]);
|
||||
ui.window.onDrawFrame?.call();
|
||||
ui.window.onReportTimings?.call(<ui.FrameTiming>[]);
|
||||
}
|
||||
|
||||
@override
|
||||
@@ -102,7 +98,7 @@ class TestServiceExtensionsBinding extends BindingBase
|
||||
}
|
||||
}
|
||||
|
||||
TestServiceExtensionsBinding binding;
|
||||
late TestServiceExtensionsBinding binding;
|
||||
|
||||
Future<Map<String, dynamic>> hasReassemble(Future<Map<String, dynamic>> pendingResult) async {
|
||||
bool completed = false;
|
||||
@@ -120,7 +116,7 @@ Future<Map<String, dynamic>> hasReassemble(Future<Map<String, dynamic>> pendingR
|
||||
}
|
||||
|
||||
void main() {
|
||||
final List<String> console = <String>[];
|
||||
final List<String?> console = <String?>[];
|
||||
|
||||
setUpAll(() async {
|
||||
binding = TestServiceExtensionsBinding()..scheduleFrame();
|
||||
@@ -150,7 +146,7 @@ void main() {
|
||||
expect(binding.frameScheduled, isFalse);
|
||||
|
||||
expect(debugPrint, equals(debugPrintThrottled));
|
||||
debugPrint = (String message, { int wrapWidth }) {
|
||||
debugPrint = (String? message, { int? wrapWidth }) {
|
||||
console.add(message);
|
||||
};
|
||||
});
|
||||
@@ -208,7 +204,7 @@ void main() {
|
||||
|
||||
bool lastValue = false;
|
||||
Future<void> _updateAndCheck(bool newValue) async {
|
||||
Map<String, dynamic> result;
|
||||
Map<String, dynamic>? result;
|
||||
binding.testExtension(
|
||||
'debugCheckElevationsEnabled',
|
||||
<String, String>{'enabled': '$newValue'},
|
||||
@@ -458,8 +454,8 @@ void main() {
|
||||
bool completed;
|
||||
|
||||
completed = false;
|
||||
ServicesBinding.instance.defaultBinaryMessenger.setMockMessageHandler('flutter/assets', (ByteData message) async {
|
||||
expect(utf8.decode(message.buffer.asUint8List()), 'test');
|
||||
ServicesBinding.instance!.defaultBinaryMessenger.setMockMessageHandler('flutter/assets', (ByteData? message) async {
|
||||
expect(utf8.decode(message!.buffer.asUint8List()), 'test');
|
||||
completed = true;
|
||||
return ByteData(5); // 0x0000000000
|
||||
});
|
||||
@@ -472,8 +468,7 @@ void main() {
|
||||
expect(completed, isTrue);
|
||||
completed = false;
|
||||
data = await rootBundle.loadStructuredData('test', (String value) async {
|
||||
expect(true, isFalse);
|
||||
return null;
|
||||
throw Error();
|
||||
});
|
||||
expect(data, isTrue);
|
||||
expect(completed, isFalse);
|
||||
@@ -486,7 +481,7 @@ void main() {
|
||||
});
|
||||
expect(data, isFalse);
|
||||
expect(completed, isTrue);
|
||||
ServicesBinding.instance.defaultBinaryMessenger.setMockMessageHandler('flutter/assets', null);
|
||||
ServicesBinding.instance!.defaultBinaryMessenger.setMockMessageHandler('flutter/assets', null);
|
||||
});
|
||||
|
||||
test('Service extensions - exit', () async {
|
||||
|
||||
@@ -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:flutter/foundation.dart';
|
||||
import '../flutter_test_alternative.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
|
||||
|
||||
@TestOn('!chrome') // web has different stack traces
|
||||
|
||||
import 'package:flutter/foundation.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 'package:flutter/foundation.dart';
|
||||
import '../flutter_test_alternative.dart';
|
||||
|
||||
@@ -11,7 +9,7 @@ void main() {
|
||||
test('SynchronousFuture control test', () async {
|
||||
final Future<int> future = SynchronousFuture<int>(42);
|
||||
|
||||
int result;
|
||||
int? result;
|
||||
future.then<void>((int value) { result = value; });
|
||||
|
||||
expect(result, equals(42));
|
||||
@@ -39,16 +37,16 @@ void main() {
|
||||
|
||||
expect(await completeResult, equals(42));
|
||||
|
||||
Object exception;
|
||||
Object? exception;
|
||||
try {
|
||||
await future.whenComplete(() {
|
||||
throw null;
|
||||
throw ArgumentError();
|
||||
});
|
||||
// Unreached.
|
||||
expect(false, isTrue);
|
||||
} catch (e) {
|
||||
exception = e;
|
||||
}
|
||||
expect(exception, isNullThrownError);
|
||||
expect(exception, isArgumentError);
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user