Movatterモバイル変換


[0]ホーム

URL:


menu
  1. Dart
  2. dart:async
  3. unawaited function
unawaited
description

unawaited function

  1. @Since("2.15")
voidunawaited(
  1. Future<void>?future
)

Explicitly ignores a future.

Not all futures need to be awaited.The Dart linter has an optional"unawaited futures" lintwhich enforces that potential futures(expressions with a static type ofFuture orFuture?)in asynchronous functions are handledsomehow.If a particular future value doesn't need to be awaited,you can callunawaited(...) with it, which will avoid the lint,simply because the expression no longer has typeFuture.Usingunawaited has no other effect.You should useunawaited to convey theintention ofdeliberately not waiting for the future.

If the future completes with an error,it was likely a mistake to not await it.That error will still occur and will be considered unhandledunless the same future is awaited (or otherwise handled) elsewhere too.Because of that,unawaited should only be used for futures thatareexpected to complete with a value.You can useFutureExtensions.ignore if you also don't want to knowabout errors from this future.

Implementation

@Since("2.15")void unawaited(Future<void>? future) {}
  1. Dart
  2. dart:async
  3. unawaited function
dart:async library

[8]ページ先頭

©2009-2025 Movatter.jp