Movatterモバイル変換


[0]ホーム

URL:


menu
  1. Dart
  2. dart:async
  3. Future<T>
  4. Future.error factory constructor
Future.error
description

Future<T>.error constructor

Future<T>.error(
  1. Objecterror, [
  2. StackTrace?stackTrace
])

Creates a future that completes with an error.

The created future will be completed with an error in a future microtask.This allows enough time for someone to add an error handler on the future.If an error handler isn't added before the future completes, the errorwill be considered unhandled.

UseCompleter to create a future and complete it later.

Example:

Future<int> getFuture() { return Future.error(Exception('Issue'));}final error = await getFuture(); // Throws.

Implementation

factory Future.error(Object error, [StackTrace? stackTrace]) =>    _Future<T>.immediateError(_interceptUserError(error, stackTrace));
  1. Dart
  2. dart:async
  3. Future<T>
  4. Future.error factory constructor
Future class

[8]ページ先頭

©2009-2025 Movatter.jp