Skip to content

CancelableOperation.isCompleted is True Before Future Completes #327

@todbachman-wf

Description

@todbachman-wf

CancelableOperation.isCompleted returns true immediately after constructing the operation even if the future it was constructed with hasn't resolved. This was unexpected to me, and I assume this is not the intended behavior. Below is a little unit test that demonstrates the problem. The expectation on the final line of the test fails, though I would expect it to succeed.

import 'dart:async';

import 'package:async/async.dart';
import 'package:test/test.dart';

void main() {
  group('CancelableOperation', () {
    test('isComplete should be false before completed', () {
      var completer = Completer<void>();
      var operation = CancelableOperation.fromFuture(completer.future);
      expect(operation.isCompleted, isFalse);
    });
  });
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions