NoUiInViewModel class

禁止在 ViewModel 代码里直接调用 UI 层 API(Navigator / ScaffoldMessenger / showDialog / showModalBottomSheet 等)。

正确做法:VM emit(EffectNavigate(...)) / emit(EffectPop(...)) / emit(EffectShowDialog(...)),由 UI 侧的 EffectListenerDefaultEffectHandler 翻译为具体的导航 / 弹窗 / 提示。

命中条件

同时满足:

  1. 代码位于一个类内部;
  2. 该类或它的祖先(含 mixin)是以下之一:
    • ViewModelNotifier / FamilyViewModelNotifier
    • AsyncViewModelNotifier / FamilyAsyncViewModelNotifier
  3. 出现以下调用:
    • Navigator.xxx(...)(任何静态/工厂方法)
    • ScaffoldMessenger.xxx(...)
    • 顶层函数:showDialog / showModalBottomSheet / showBottomSheet / showGeneralDialog / showMenu / showDatePicker / showTimePicker / showAboutDialog

Constructors

NoUiInViewModel()
const

Properties

code → LintCode
The LintCode that this LintRule may emit.
finalinherited
enabledByDefault bool
Whether the lint rule is on or off by default in an empty analysis_options.yaml
no setterinherited
filesToAnalyze List<String>
A list of glob patterns matching the files that run cares about.
no setterinherited
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited

Methods

getFixes() List<Fix>
Obtains the list of Fix associated with this LintRule.
inherited
isEnabled(CustomLintConfigs configs) bool
Checks whether this lint rule is enabled in a configuration file.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
run(CustomLintResolver resolver, ErrorReporter reporter, CustomLintContext context) → void
Emits lints for a given file.
startUp(CustomLintResolver resolver, CustomLintContext context) Future<void>
Emits lints for a given file.
inherited
testAnalyzeAndRun(File file) Future<List<AnalysisError>>
Analyze a Dart file and runs this assist in test mode.
inherited
testRun(ResolvedUnitResult result, {Pubspec? pubspec}) Future<List<AnalysisError>>
Runs this assist in test mode.
inherited
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited