Enable avoid_print lint. (#91332)

This commit is contained in:
Ian Hickson
2021-10-07 09:53:03 -07:00
committed by GitHub
parent 3c6c2aa50a
commit cb378edc9e
85 changed files with 359 additions and 246 deletions

View File

@@ -27,6 +27,9 @@ void tryToDelete(Directory directory) {
directory.deleteSync(recursive: true);
}
} on FileSystemException catch (error) {
// We print this so that it's visible in the logs, to get an idea of how
// common this problem is, and if any patterns are ever noticed by anyone.
// ignore: avoid_print
print('Failed to delete ${directory.path}: $error');
}
}

View File

@@ -127,7 +127,7 @@ void testUsingContext(
},
body: () {
final String flutterRoot = getFlutterRoot();
return runZoned<Future<dynamic>>(() {
return runZonedGuarded<Future<dynamic>>(() {
try {
return context.run<dynamic>(
// Apply the overrides to the test context in the zone since their
@@ -148,9 +148,10 @@ void testUsingContext(
_printBufferedErrors(context);
rethrow;
}
}, onError: (Object error, StackTrace stackTrace) { // ignore: deprecated_member_use
print(error);
print(stackTrace);
}, (Object error, StackTrace stackTrace) {
// When things fail, it's ok to print to the console!
print(error); // ignore: avoid_print
print(stackTrace); // ignore: avoid_print
_printBufferedErrors(context);
throw error;
});
@@ -176,7 +177,9 @@ void _printBufferedErrors(AppContext testContext) {
if (testContext.get<Logger>() is BufferLogger) {
final BufferLogger bufferLogger = testContext.get<Logger>() as BufferLogger;
if (bufferLogger.errorText.isNotEmpty) {
print(bufferLogger.errorText);
// This is where the logger outputting errors is implemented, so it has
// to use `print`.
print(bufferLogger.errorText); // ignore: avoid_print
}
bufferLogger.clear();
}