avoid_slow_async_io
Details about the 'avoid_slow_async_io' diagnostic produced by the Dart analyzer.
Use of an async 'dart:io' method.
Description
#The analyzer produces this diagnostic when an asynchronous file I/O method with a synchronous equivalent is used.
The following are the specific flagged asynchronous methods:
Directory.existsDirectory.statFile.lastModifiedFile.existsFile.statFileSystemEntity.isDirectoryFileSystemEntity.isFileFileSystemEntity.isLinkFileSystemEntity.type
Example
#
The following code produces this diagnostic because the async method
exists is invoked:
dart
import 'dart:io';
Future<void> g(File f) async {
await f.exists();
}
Common fixes
#Use the synchronous version of the method:
dart
import 'dart:io';
void g(File f) {
f.existsSync();
}
Was this page's content helpful?
除非另有说明,文档之所提及适用于 Dart 3.10.3 版本报告页面问题.