prefix_collides_with_top_level_member
The name '{0}' is already used as an import prefix and can't be used to name a top-level element.
Description
#The analyzer produces this diagnostic when a name is used as both an import prefix and the name of a top-level declaration in the same library.
Example
#The following code produces this diagnostic because f
is used as both an import prefix and the name of a function:
import 'dart:math' as f;
int f() => f.min(0, 1);
Common fixes
#If you want to use the name for the import prefix, then rename the top-level declaration:
import 'dart:math' as f;
int g() => f.min(0, 1);
If you want to use the name for the top-level declaration, then rename the import prefix:
import 'dart:math' as math;
int f() => math.min(0, 1);
Unless stated otherwise, the documentation on this site reflects Dart 3.7.3. Page last updated on 2025-05-08. View source or report an issue.