Skip to main content

inconsistent_language_version_override

Parts must have exactly the same language version override as the library.

Description

#

The analyzer produces this diagnostic when a part filePart fileA Dart source file that contains a `part of` directive. Learn more has a language version override comment that specifies a different language version than the one being used for the library to which the part belongs.

Example

#

Given a part filePart fileA Dart source file that contains a `part of` directive. Learn more named part.dart that contains the following:

dart
// @dart = 2.14
part of 'test.dart';

The following code produces this diagnostic because the parts of a library must have the same language version as the defining compilation unit:

dart
// @dart = 2.15
part 'part.dart';

Common fixes

#

Remove the language version override from the part filePart fileA Dart source file that contains a `part of` directive. Learn more, so that it implicitly uses the same version as the defining compilation unit:

dart
part of 'test.dart';

If necessary, either adjust the language version override in the defining compilation unit to be appropriate for the code in the part, or migrate the code in the part filePart fileA Dart source file that contains a `part of` directive. Learn more to be consistent with the new language version.