Skip to main content

deprecated_web_configuration

Details about the 'deprecated_web_configuration' diagnostic produced by the Dart analyzer.

'dart:{0}' is deprecated and shouldn't be used as an import/export configuration.

Description

#

The analyzer produces this diagnostic when a deprecated library is used in an import configuration. The following web libraries are deprecated: 'dart:html', 'dart:indexed_db', 'dart:js', 'dart:js_util', 'dart:svg', 'dart:web_audio', 'dart:web_gl'.

Example

#

Given a package containing a file named a.dart:

dart
class C {}

a file named a_io.dart:

dart
class C {}

and a file named a_web.dart:

dart
class C {}

The following code produces this diagnostic because the configuration uses the dotted identifier dart.library.html:

dart
import 'src/a.dart'
    if (dart.library.io) 'src/a_io.dart'
    if (dart.library.html) 'src/a_web.dart';
​
var c = C();

Common fixes

#

The typical fix is to use the dart.library.js_interop configuration:

dart
import 'src/a.dart'
    if (dart.library.io) 'src/a_io.dart'
    if (dart.library.js_interop) 'src/a_web.dart';
​
var c = C();