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:
dart
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:
dart
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:
dart
import 'dart:math' as math;
int f() => math.min(0, 1);
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。