This reverts commit e2490f2906.
This commit is contained in:
@@ -185,11 +185,11 @@ mixin CommandHandlerFactory {
|
||||
Future<Health> _getHealth(Command command) async => const Health(HealthStatus.ok);
|
||||
|
||||
Future<LayerTree> _getLayerTree(Command command) async {
|
||||
return LayerTree(RendererBinding.instance.renderView.debugLayer?.toStringDeep());
|
||||
return LayerTree(RendererBinding.instance?.renderView.debugLayer?.toStringDeep());
|
||||
}
|
||||
|
||||
Future<RenderTree> _getRenderTree(Command command) async {
|
||||
return RenderTree(RendererBinding.instance.renderView.toStringDeep());
|
||||
return RenderTree(RendererBinding.instance?.renderView.toStringDeep());
|
||||
}
|
||||
|
||||
Future<Result> _enterText(Command command) async {
|
||||
@@ -258,8 +258,8 @@ mixin CommandHandlerFactory {
|
||||
'This feature was deprecated after v1.9.3.'
|
||||
)
|
||||
Future<Result> _waitUntilNoTransientCallbacks(Command command) async {
|
||||
if (SchedulerBinding.instance.transientCallbackCount != 0)
|
||||
await _waitUntilFrame(() => SchedulerBinding.instance.transientCallbackCount == 0);
|
||||
if (SchedulerBinding.instance!.transientCallbackCount != 0)
|
||||
await _waitUntilFrame(() => SchedulerBinding.instance!.transientCallbackCount == 0);
|
||||
return Result.empty;
|
||||
}
|
||||
|
||||
@@ -288,8 +288,8 @@ mixin CommandHandlerFactory {
|
||||
)
|
||||
Future<Result> _waitUntilNoPendingFrame(Command command) async {
|
||||
await _waitUntilFrame(() {
|
||||
return SchedulerBinding.instance.transientCallbackCount == 0
|
||||
&& !SchedulerBinding.instance.hasScheduledFrame;
|
||||
return SchedulerBinding.instance!.transientCallbackCount == 0
|
||||
&& !SchedulerBinding.instance!.hasScheduledFrame;
|
||||
});
|
||||
return Result.empty;
|
||||
}
|
||||
@@ -428,17 +428,17 @@ mixin CommandHandlerFactory {
|
||||
}
|
||||
|
||||
SemanticsHandle? _semantics;
|
||||
bool get _semanticsIsEnabled => RendererBinding.instance.pipelineOwner.semanticsOwner != null;
|
||||
bool get _semanticsIsEnabled => RendererBinding.instance!.pipelineOwner.semanticsOwner != null;
|
||||
|
||||
Future<SetSemanticsResult> _setSemantics(Command command) async {
|
||||
final SetSemantics setSemanticsCommand = command as SetSemantics;
|
||||
final bool semanticsWasEnabled = _semanticsIsEnabled;
|
||||
if (setSemanticsCommand.enabled && _semantics == null) {
|
||||
_semantics = RendererBinding.instance.pipelineOwner.ensureSemantics();
|
||||
_semantics = RendererBinding.instance!.pipelineOwner.ensureSemantics();
|
||||
if (!semanticsWasEnabled) {
|
||||
// wait for the first frame where semantics is enabled.
|
||||
final Completer<void> completer = Completer<void>();
|
||||
SchedulerBinding.instance.addPostFrameCallback((Duration d) {
|
||||
SchedulerBinding.instance!.addPostFrameCallback((Duration d) {
|
||||
completer.complete();
|
||||
});
|
||||
await completer.future;
|
||||
@@ -456,19 +456,19 @@ mixin CommandHandlerFactory {
|
||||
'This feature was deprecated after v1.9.3.'
|
||||
)
|
||||
Future<Result> _waitUntilFirstFrameRasterized(Command command) async {
|
||||
await WidgetsBinding.instance.waitUntilFirstFrameRasterized;
|
||||
await WidgetsBinding.instance!.waitUntilFirstFrameRasterized;
|
||||
return Result.empty;
|
||||
}
|
||||
|
||||
/// Runs `finder` repeatedly until it finds one or more [Element]s.
|
||||
Future<Finder> waitForElement(Finder finder) async {
|
||||
if (_frameSync)
|
||||
await _waitUntilFrame(() => SchedulerBinding.instance.transientCallbackCount == 0);
|
||||
await _waitUntilFrame(() => SchedulerBinding.instance!.transientCallbackCount == 0);
|
||||
|
||||
await _waitUntilFrame(() => finder.evaluate().isNotEmpty);
|
||||
|
||||
if (_frameSync)
|
||||
await _waitUntilFrame(() => SchedulerBinding.instance.transientCallbackCount == 0);
|
||||
await _waitUntilFrame(() => SchedulerBinding.instance!.transientCallbackCount == 0);
|
||||
|
||||
return finder;
|
||||
}
|
||||
@@ -476,12 +476,12 @@ mixin CommandHandlerFactory {
|
||||
/// Runs `finder` repeatedly until it finds zero [Element]s.
|
||||
Future<Finder> waitForAbsentElement(Finder finder) async {
|
||||
if (_frameSync)
|
||||
await _waitUntilFrame(() => SchedulerBinding.instance.transientCallbackCount == 0);
|
||||
await _waitUntilFrame(() => SchedulerBinding.instance!.transientCallbackCount == 0);
|
||||
|
||||
await _waitUntilFrame(() => finder.evaluate().isEmpty);
|
||||
|
||||
if (_frameSync)
|
||||
await _waitUntilFrame(() => SchedulerBinding.instance.transientCallbackCount == 0);
|
||||
await _waitUntilFrame(() => SchedulerBinding.instance!.transientCallbackCount == 0);
|
||||
|
||||
return finder;
|
||||
}
|
||||
@@ -490,7 +490,7 @@ mixin CommandHandlerFactory {
|
||||
Future<void> _waitUntilFrame(bool Function() condition, [ Completer<void>? completer ]) {
|
||||
completer ??= Completer<void>();
|
||||
if (!condition()) {
|
||||
SchedulerBinding.instance.addPostFrameCallback((Duration timestamp) {
|
||||
SchedulerBinding.instance!.addPostFrameCallback((Duration timestamp) {
|
||||
_waitUntilFrame(condition, completer);
|
||||
});
|
||||
} else {
|
||||
|
||||
@@ -334,7 +334,7 @@ class FlutterDriverExtension with DeserializeFinderFactory, CreateFinderFactory,
|
||||
}
|
||||
}
|
||||
|
||||
final WidgetController _prober = LiveWidgetController(WidgetsBinding.instance);
|
||||
final WidgetController _prober = LiveWidgetController(WidgetsBinding.instance!);
|
||||
|
||||
final DataHandler? _requestDataHandler;
|
||||
|
||||
@@ -364,7 +364,7 @@ class FlutterDriverExtension with DeserializeFinderFactory, CreateFinderFactory,
|
||||
final String commandKind = params['command']!;
|
||||
try {
|
||||
final Command command = deserializeCommand(params, this);
|
||||
assert(WidgetsBinding.instance.isRootWidgetAttached || !command.requiresRootWidgetAttached,
|
||||
assert(WidgetsBinding.instance!.isRootWidgetAttached || !command.requiresRootWidgetAttached,
|
||||
'No root widget is attached; have you remembered to call runApp()?');
|
||||
Future<Result?> responseFuture = handleCommand(command, _prober, this);
|
||||
if (command.timeout != null)
|
||||
|
||||
@@ -49,12 +49,12 @@ class _InternalNoTransientCallbacksCondition implements WaitCondition {
|
||||
}
|
||||
|
||||
@override
|
||||
bool get condition => SchedulerBinding.instance.transientCallbackCount == 0;
|
||||
bool get condition => SchedulerBinding.instance!.transientCallbackCount == 0;
|
||||
|
||||
@override
|
||||
Future<void> wait() async {
|
||||
while (!condition) {
|
||||
await SchedulerBinding.instance.endOfFrame;
|
||||
await SchedulerBinding.instance!.endOfFrame;
|
||||
}
|
||||
assert(condition);
|
||||
}
|
||||
@@ -77,12 +77,12 @@ class _InternalNoPendingFrameCondition implements WaitCondition {
|
||||
}
|
||||
|
||||
@override
|
||||
bool get condition => !SchedulerBinding.instance.hasScheduledFrame;
|
||||
bool get condition => !SchedulerBinding.instance!.hasScheduledFrame;
|
||||
|
||||
@override
|
||||
Future<void> wait() async {
|
||||
while (!condition) {
|
||||
await SchedulerBinding.instance.endOfFrame;
|
||||
await SchedulerBinding.instance!.endOfFrame;
|
||||
}
|
||||
assert(condition);
|
||||
}
|
||||
@@ -105,11 +105,11 @@ class _InternalFirstFrameRasterizedCondition implements WaitCondition {
|
||||
}
|
||||
|
||||
@override
|
||||
bool get condition => WidgetsBinding.instance.firstFrameRasterized;
|
||||
bool get condition => WidgetsBinding.instance!.firstFrameRasterized;
|
||||
|
||||
@override
|
||||
Future<void> wait() async {
|
||||
await WidgetsBinding.instance.waitUntilFirstFrameRasterized;
|
||||
await WidgetsBinding.instance!.waitUntilFirstFrameRasterized;
|
||||
assert(condition);
|
||||
}
|
||||
}
|
||||
@@ -132,13 +132,13 @@ class _InternalNoPendingPlatformMessagesCondition implements WaitCondition {
|
||||
|
||||
@override
|
||||
bool get condition {
|
||||
final TestDefaultBinaryMessenger binaryMessenger = ServicesBinding.instance.defaultBinaryMessenger as TestDefaultBinaryMessenger;
|
||||
final TestDefaultBinaryMessenger binaryMessenger = ServicesBinding.instance!.defaultBinaryMessenger as TestDefaultBinaryMessenger;
|
||||
return binaryMessenger.pendingMessageCount == 0;
|
||||
}
|
||||
|
||||
@override
|
||||
Future<void> wait() async {
|
||||
final TestDefaultBinaryMessenger binaryMessenger = ServicesBinding.instance.defaultBinaryMessenger as TestDefaultBinaryMessenger;
|
||||
final TestDefaultBinaryMessenger binaryMessenger = ServicesBinding.instance!.defaultBinaryMessenger as TestDefaultBinaryMessenger;
|
||||
while (!condition) {
|
||||
await binaryMessenger.platformMessagesFinished;
|
||||
}
|
||||
|
||||
@@ -55,7 +55,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('waits until no transient callbacks', (WidgetTester tester) async {
|
||||
SchedulerBinding.instance.scheduleFrameCallback((_) {
|
||||
SchedulerBinding.instance!.scheduleFrameCallback((_) {
|
||||
// Intentionally blank. We only care about existence of a callback.
|
||||
});
|
||||
|
||||
@@ -116,7 +116,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('waiting for NoTransientCallbacks returns until no transient callbacks', (WidgetTester tester) async {
|
||||
SchedulerBinding.instance.scheduleFrameCallback((_) {
|
||||
SchedulerBinding.instance!.scheduleFrameCallback((_) {
|
||||
// Intentionally blank. We only care about existence of a callback.
|
||||
});
|
||||
|
||||
@@ -158,7 +158,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('waiting for NoPendingFrame returns until no pending scheduled frame', (WidgetTester tester) async {
|
||||
SchedulerBinding.instance.scheduleFrame();
|
||||
SchedulerBinding.instance!.scheduleFrame();
|
||||
|
||||
driverExtension.call(const WaitForCondition(NoPendingFrame()).serialize())
|
||||
.then<void>(expectAsync1((Map<String, dynamic> r) {
|
||||
@@ -201,8 +201,8 @@ void main() {
|
||||
|
||||
testWidgets(
|
||||
'waiting for combined conditions returns until no transient callbacks', (WidgetTester tester) async {
|
||||
SchedulerBinding.instance.scheduleFrame();
|
||||
SchedulerBinding.instance.scheduleFrameCallback((_) {
|
||||
SchedulerBinding.instance!.scheduleFrame();
|
||||
SchedulerBinding.instance!.scheduleFrameCallback((_) {
|
||||
// Intentionally blank. We only care about existence of a callback.
|
||||
});
|
||||
|
||||
@@ -230,8 +230,8 @@ void main() {
|
||||
|
||||
testWidgets(
|
||||
'waiting for combined conditions returns until no pending scheduled frame', (WidgetTester tester) async {
|
||||
SchedulerBinding.instance.scheduleFrame();
|
||||
SchedulerBinding.instance.scheduleFrameCallback((_) {
|
||||
SchedulerBinding.instance!.scheduleFrame();
|
||||
SchedulerBinding.instance!.scheduleFrameCallback((_) {
|
||||
// Intentionally blank. We only care about existence of a callback.
|
||||
});
|
||||
|
||||
@@ -466,7 +466,7 @@ void main() {
|
||||
});
|
||||
|
||||
testWidgets('works when semantics are enabled', (WidgetTester tester) async {
|
||||
final SemanticsHandle semantics = RendererBinding.instance.pipelineOwner.ensureSemantics();
|
||||
final SemanticsHandle semantics = RendererBinding.instance!.pipelineOwner.ensureSemantics();
|
||||
await tester.pumpWidget(
|
||||
const Text('hello', textDirection: TextDirection.ltr));
|
||||
|
||||
@@ -490,7 +490,7 @@ void main() {
|
||||
}, semanticsEnabled: false);
|
||||
|
||||
testWidgets('throws state error multiple matches are found', (WidgetTester tester) async {
|
||||
final SemanticsHandle semantics = RendererBinding.instance.pipelineOwner.ensureSemantics();
|
||||
final SemanticsHandle semantics = RendererBinding.instance!.pipelineOwner.ensureSemantics();
|
||||
await tester.pumpWidget(
|
||||
Directionality(
|
||||
textDirection: TextDirection.ltr,
|
||||
@@ -1193,7 +1193,7 @@ void main() {
|
||||
|
||||
testWidgets(
|
||||
'waits until no transient callbacks', (WidgetTester tester) async {
|
||||
SchedulerBinding.instance.scheduleFrameCallback((_) {
|
||||
SchedulerBinding.instance!.scheduleFrameCallback((_) {
|
||||
// Intentionally blank. We only care about existence of a callback.
|
||||
});
|
||||
|
||||
@@ -1219,7 +1219,7 @@ void main() {
|
||||
|
||||
testWidgets(
|
||||
'waits until no pending scheduled frame', (WidgetTester tester) async {
|
||||
SchedulerBinding.instance.scheduleFrame();
|
||||
SchedulerBinding.instance!.scheduleFrame();
|
||||
|
||||
driverExtension.call(const WaitForCondition(NoPendingFrame()).serialize())
|
||||
.then<void>(expectAsync1((Map<String, dynamic> r) {
|
||||
|
||||
Reference in New Issue
Block a user