private_collision_in_mixin_application
The private name '{0}', defined by '{1}', conflicts with the same name defined by '{2}'.
Description
#The analyzer produces this diagnostic when two mixins that define the same private member are used together in a single class in a library other than the one that defines the mixins.
Example
#Given a file a.dart
containing the following code:
dart
mixin A {
void _foo() {}
}
mixin B {
void _foo() {}
}
The following code produces this diagnostic because the mixins A
and B
both define the method _foo
:
dart
import 'a.dart';
class C extends Object with A, B {}
Common fixes
#If you don't need both of the mixins, then remove one of them from the
with
clause:
dart
import 'a.dart';
class C extends Object with A, B {}
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。