uri_with_interpolation
URIs can't use string interpolation.
Description
#The analyzer produces this diagnostic when the string literal in an
import
, export
, or part
directive contains an interpolation. The
resolution of the URIs in directives must happen before the declarations
are compiled, so expressions can't be evaluated while determining the
values of the URIs.
Example
#The following code produces this diagnostic because the string in the
import
directive contains an interpolation:
dart
import 'dart:$m';
const m = 'math';
Common fixes
#Remove the interpolation from the URI:
dart
import 'dart:math';
var zero = min(0, 0);
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。