跳转至主要内容

export_legacy_symbol

The symbol '{0}' is defined in a legacy library, and can't be re-exported from a library with null safety enabled.

Description

#

The analyzer produces this diagnostic when a library that was opted in to null safety exports another library, and the exported library is opted out of null safety.

Example

#

Given a library that is opted out of null safety:

dart
// @dart = 2.8
String s;

The following code produces this diagnostic because it's exporting symbols from an opted-out library:

dart
export 'optedOut.dart';

class C {}

Common fixes

#

If you're able to do so, migrate the exported library so that it doesn't need to opt out:

dart
String? s;

If you can't migrate the library, then remove the export:

dart
class C {}