result property
A future that completes when the task finishes (either success or failure).
This is a convenience for events.firstWhere((e) => !e.isStarted).
Note: If the app is terminated and restarted, this future will never complete because the stream is transient. For long-running tasks, always use NativeWorkManager.getTaskStatus or NativeWorkManager.events subscription for robust state management.
Implementation
Future<TaskEvent> get result =>
events.firstWhere((e) => !e.isStarted).timeout(
const Duration(days: 7), // Long timeout for background tasks
onTimeout: () => throw TimeoutException(
'Task $taskId did not complete within 7 days or was lost.',
),
);