Skip to content

Cast error when awaiting enumerateDevices() #39627

Closed
@davidjenkins

Description

@davidjenkins

Dart version 2.7.0 (build 2.7.0-dev.2.1 e4344a5) -- included with Flutter (Win 10 x64)

This issue also occurs in current dev branch of Flutter, which uses Dart 2.7.0 (not sure if "2.7.0" alone means "2.7.0-dev0.0").

If I try this:

import 'dart:html';
// ...
await window.navigator.mediaDevices.enumerateDevices();

Then I get this (in Chrome):

Type 'List<dynamic>' should be 'List<MediaDeviceInfo>' to implement expected type 'FutureOr<List<MediaDeviceInfo>>'.

Full stack:

errors.dart:147 Uncaught (in promise) Error: Type 'List<dynamic>' should be 'List<MediaDeviceInfo>' to implement expected type 'FutureOr<List<MediaDeviceInfo>>'.
    at Object.throw_ [as throw] (errors.dart:196)
    at Object.castError (errors.dart:45)
    at Object.cast [as as] (operations.dart:426)
    at Function.check_FutureOr [as _check] (future.dart:44)
    at js_util_dart2js.dart:145

Metadata

Metadata

Assignees

Labels

area-web-jsIssues related to JavaScript support for Dart Web, including DDC, dart2js, and JS interop.web-librariesIssues impacting dart:html, etc., libraries

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions