Skip to content

Will need runtime check to cast to type (WebElement) -> dynamic #25018

Closed
@zoechi

Description

@zoechi
  return driver
      .findElements(buttonsSelector)
      .asyncMap((WebElement e) async => {'button': e, 'text': await e.text})
             // ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      .where((Map m) => m['text'] == text)
      .map((Map m) => m['button'])
      .first as WebElement;

Warning:(589, 17) (WebElement e) async => {'button' : e, 'text' : await e.text} ((WebElement) → Future<Map<dynamic, dynamic>>) will need runtime check to cast to type (WebElement) → dynamic

I don't get this warning here

final List<WebElement> cells =
      await (await driver
              .findElements(firstColumnSelector)
              .asyncMap(
                  (WebElement e) async => {'element': e, 'text': await e.text})
              .where((Map item) => item['text'] == taskTitle))
          .map((Map item) => item['element'])
          .toList() as List<WebElement>;

strong-mode is enabled

I think either the first shouldn't produce a warning or the second should.
If the warning is correct, is a typedef the only way to silence this?

Metadata

Metadata

Assignees

Labels

P2A bug or feature request we're likely to work onlegacy-area-analyzerUse area-devexp instead.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions