avoid_slow_async_io

Group: errors

Maturity: stable

Linter v0.1.30

Since info is static, may be stale

View all Lint Rules

Using the Linter

AVOID using the following asynchronous file I/O methods because they are much slower than their synchronous counterparts.

BAD:

import 'dart:io';

Future<Null> someFunction() async {
  var file = File('/path/to/my/file');
  var now = DateTime.now();
  if ((await file.lastModified()).isBefore(now)) print('before'); // LINT
}

GOOD:

import 'dart:io';

Future<Null> someFunction() async {
  var file = File('/path/to/my/file');
  var now = DateTime.now();
  if (file.lastModifiedSync().isBefore(now)) print('before'); // OK
}