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:
import 'dart:$m';
const m = 'math';
Common fixes
#Remove the interpolation from the URI:
import 'dart:math';
var zero = min(0, 0);
Unless stated otherwise, the documentation on this site reflects Dart 3.9.2. Page last updated on 2025-9-1. View source or report an issue.