Future.error(
Object error,
[StackTrace stackTrace]
)

A future that completes with an error in the next event-loop iteration.

If error is null, it is replaced by a NullThrownError.

Use Completer to create a future and complete it later.