refactor context to be implicit-downcast safe (#31622)

This commit is contained in:
Jonah Williams
2019-04-25 15:51:08 -07:00
committed by GitHub
parent 0e5d771a2a
commit 0acd3e6b04
56 changed files with 144 additions and 127 deletions

View File

@@ -30,10 +30,10 @@ import 'common.dart';
export 'package:flutter_tools/src/base/context.dart' show Generator;
/// Return the test logger. This assumes that the current Logger is a BufferLogger.
BufferLogger get testLogger => context[Logger];
BufferLogger get testLogger => context.get<Logger>();
MockDeviceManager get testDeviceManager => context[DeviceManager];
MockDoctor get testDoctor => context[Doctor];
MockDeviceManager get testDeviceManager => context.get<DeviceManager>();
MockDoctor get testDoctor => context.get<Doctor>();
typedef ContextInitializer = void Function(AppContext testContext);
@@ -126,8 +126,8 @@ void testUsingContext(
}
void _printBufferedErrors(AppContext testContext) {
if (testContext[Logger] is BufferLogger) {
final BufferLogger bufferLogger = testContext[Logger];
if (testContext.get<Logger>() is BufferLogger) {
final BufferLogger bufferLogger = testContext.get<Logger>();
if (bufferLogger.errorText.isNotEmpty)
print(bufferLogger.errorText);
bufferLogger.clear();