Skip to content

await quickfix overwrite FutureOr type declarationΒ #59838

@stephane-archer

Description

@stephane-archer

Input code:

class _A extends AsyncNotifier<img.Image?> {
  @override
  FutureOr<img.Image?> build() {
    var a =  await   ref.watch(refImageCompatiblePathProvider.future);
    // TODO: implement build
    throw UnimplementedError();
  }
}

The await expression can only be used in an async function. Try marking the function body with either 'async' or 'async*'.

Apply quick fix:

class _A extends AsyncNotifier<img.Image?> {
  @override
  Future<img.Image?> build() async {
    var a =  await   ref.watch(refImageCompatiblePathProvider.future);
    // TODO: implement build
    throw UnimplementedError();
  }
}

Expected code:

class _A extends AsyncNotifier<img.Image?> {
  @override
  FutureOr<img.Image?> build() async {
    var a = await ref.watch(refImageCompatiblePathProvider.future);
    // TODO: implement build
    throw UnimplementedError();
  }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    P4area-devexpFor issues related to the analysis server, IDE support, linter, `dart fix`, and diagnostic messages.devexp-quick-fixIssues with analysis server (quick) fixestype-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions