implicit_reopen
Don't implicitly reopen classes.
This rule is currently experimental and available as of Dart 3.0.
This rule has a quick fix available.
Details
#Using an interface
, base
, final
, or sealed
modifier on a class,
or a base
modifier on a mixin,
authors can control whether classes and mixins allow being implemented,
extended, and/or mixed in from outside of the library where they're defined.
In some cases, it's possible for an author to inadvertently relax these controls
and implicitly "reopen" a class. (A similar reopening cannot occur with a mixin.)
This lint guards against unintentionally reopening a class by requiring such
cases to be made explicit with the
@reopen
annotation in package:meta
.
BAD:
interface class I {}
class C extends I {} // LINT
GOOD:
interface class I {}
final class C extends I {}
import 'package:meta/meta.dart';
interface class I {}
@reopen
class C extends I {}
Usage
#To enable the implicit_reopen
rule,
add implicit_reopen
under linter > rules in your
analysis_options.yaml
file:
linter:
rules:
- implicit_reopen
除非另有说明,文档之所提及适用于 Dart 3.6.0 版本,本页面最后更新时间: 2024-08-02。 查看文档源码 或者 报告页面问题。