PreferAnimationControllerForwardFromZeroRule class

Flags AnimationController.forward() (no args) inside a press/tap gesture callback when the controller is wired to auto-reverse on completion (addStatusListenerreverse() on AnimationStatus.completed — the canonical "press-and-bounce" pattern).

Without from: 0.0, a rapid re-press while the controller is still mid-reverse resumes forward from the in-flight value instead of restarting from zero, so the animation plays only the remaining fraction of its duration. The visible effect is a sticky / uneven re-press: the first press animates for the full duration, a fast second press finishes in a fraction of the time. Users feel the UI respond "slippery" on rapid taps without being able to name why.

Since: v12.3.5 | Rule version: v1

BAD:

class _InkState extends State<InkButton>
    with SingleTickerProviderStateMixin {
  late final AnimationController _c;

  @override
  void initState() {
    super.initState();
    _c = AnimationController(vsync: this, ...);
    _c.addStatusListener((s) {
      if (s == AnimationStatus.completed) _c.reverse();
    });
  }

  @override
  Widget build(BuildContext context) => InkResponse(
        onTap: () => _c.forward(), // LINT — sticky on rapid re-press
        child: ...,
      );
}

GOOD:

onTap: () => _c.forward(from: 0.0),

GOOD: Equivalent explicit reset before forward.

onTap: () {
  _c.reset();
  _c.forward();
},
Inheritance

Properties

accuracyTarget AccuracyTarget?
Optional accuracy target for this rule (for documentation and tooling). Does not enforce; used by reports and rule-audit scripts.
no setterinherited
applicableFileTypes Set<FileType>?
The file types this rule applies to.
no setteroverride
canUseParsedResult bool
Indicates whether this analysis rule can work with just the parsed information or if it requires a resolved unit.
no setterinherited
certIds List<String>
CERT coding standard identifiers (e.g. STR02-C). Populate only where there is a clear mapping; leave empty for most rules initially.
no setterinherited
code → LintCode
The lint code for this rule.
no setterinherited
configAliases List<String>
Alternate config keys that can be used to reference this rule.
no setterinherited
conflictingRules List<String>
Curated opposite/competing rule names.
no setterinherited
cost RuleCost
Class-body scan + descendant visitor per class; cheaper than a full-file recursive walk but not as cheap as a single visitor callback.
no setteroverride
cweIds List<int>
CWE identifiers this rule helps prevent or detect. https://cwe.mitre.org/ — e.g. CWE-798 (Hardcoded Credentials).
no setterinherited
description String
Short description suitable for display in console output and IDEs.
finalinherited
diagnosticCode → DiagnosticCode
The code to report for a violation.
no setterinherited
diagnosticCodes List<DiagnosticCode>
The diagnostic codes associated with this analysis rule.
no setterinherited
documentationUrl String
Returns the documentation URL for this rule.
no setterinherited
effectiveSeverity → DiagnosticSeverity?
Get the effective severity for this rule, considering overrides.
no setterinherited
exampleBad String?
Short code example that VIOLATES this rule (shown in CLI walkthrough).
no setterinherited
exampleGood String?
Short code example of COMPLIANT code (shown in CLI walkthrough).
no setterinherited
fixGenerators List<SaropaFixGenerator>
Fix producer generators for this rule.
no setteroverride
hashCode int
The hash code for this object.
no setterinherited
hyphenatedName String
Returns the rule name in hyphenated format for display.
no setterinherited
impact LintImpact
UX correctness bug: rapid re-presses render only part of the animation, so every second tap looks different from the first. Not a crash or leak; QA rarely catches it because the regression is time-correlated. Narrow trigger keeps false positives low.
no setteroverride
incompatibleRules List<String>
A list of incompatible rule names.
no setterinherited
isDisabled bool
Check if this rule is disabled via configuration.
no setterinherited
maximumLineCount int
Maximum line count for this rule to run.
no setterinherited
minimumLineCount int
Minimum line count for this rule to run.
no setterinherited
name String
The rule name.
finalinherited
owasp OwaspMapping?
OWASP categories this rule helps prevent.
no setterinherited
pubspecVisitor → PubspecVisitor?
A visitor that visits a Pubspec to perform analysis.
no setterinherited
relatedRules List<String>
Curated "see also" rule names for discoverability in docs/IDE tooling.
no setterinherited
reporter ← DiagnosticReporter
Sets the DiagnosticReporter for the CompilationUnit currently being visited.
no getterinherited
requiredPatterns Set<String>?
Files that never wire a status listener cannot match — skip entirely. Single-token prefilter intentionally: requiredPatterns uses OR semantics, so adding a second token would broaden the prefilter (files with only .forward( would no longer skip). The status listener is the strictly-required token, so it alone is the tightest gate.
no setteroverride
requiresAsync bool
Whether this rule only applies to async code.
no setterinherited
requiresBlocImport bool
Whether this rule only applies to files that import Bloc.
no setterinherited
requiresClassDeclaration bool
Whether this rule only applies to files with class declarations.
no setterinherited
requiresFlutterImport bool
Whether this rule only applies to files that import Flutter.
no setterinherited
requiresImports bool
Whether this rule only applies to files with imports.
no setterinherited
requiresMainFunction bool
Whether this rule only applies to files with a main() function.
no setterinherited
requiresProviderImport bool
Whether this rule only applies to files that import Provider.
no setterinherited
requiresRiverpodImport bool
Whether this rule only applies to files that import Riverpod.
no setterinherited
requiresWidgets bool
Whether this rule only applies to Flutter widget code.
no setterinherited
ruleStatus RuleStatus
Lifecycle status. Default RuleStatus.ready. Use RuleStatus.beta for new or heuristic-heavy rules; RuleStatus.deprecated for sunset.
no setterinherited
ruleType RuleType?
Semantic type of this rule. Default null = unspecified (legacy). When set, used for quality gates, accuracy targets, and reporting.
no setteroverride
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
skipExampleFiles bool
Whether to skip example files (example/**).
no setterinherited
skipFixtureFiles bool
Whether to skip fixture files (fixture/, fixtures/).
no setterinherited
skipGeneratedCode bool
Whether to skip generated files (*.g.dart, *.freezed.dart, *.gen.dart).
no setterinherited
skipTestFiles bool
Whether to skip test files (*_test.dart, test/**).
no setterinherited
state → RuleState
The state of this analysis rule.
finalinherited
supersedesRules List<String>
Rule names this rule supersedes/replaces.
no setterinherited
tags Set<String>
Tags for filtering and discovery (e.g. in docs, IDE, or CI). Examples: 'performance', 'accessibility', 'suspicious', 'convention'.
no setteroverride
testRelevance TestRelevance
How this rule relates to test files.
no setterinherited
usesTypeResolution bool
Whether this rule triggers lazy cross-library type resolution in the analyzer (e.g. .staticType, .library, .allSupertypes, .enclosingElement).
no setteroverride

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
registerNodeProcessors(RuleVisitorRegistry registry, RuleContext context) → void
Registers node processors in the given registry.
inherited
reportAtNode(AstNode? node, {List<Object> arguments = const [], List<DiagnosticMessage>? contextMessages}) → Diagnostic?
Reports a diagnostic at node with message arguments and contextMessages.
inherited
reportAtOffset(int offset, int length, {List<Object> arguments = const [], List<DiagnosticMessage>? contextMessages}) → Diagnostic
Reports a diagnostic at offset, with length, with message arguments and contextMessages.
inherited
reportAtPubNode(PubspecNode node, {List<Object> arguments = const [], List<DiagnosticMessage> contextMessages = const []}) → Diagnostic
Reports a diagnostic at Pubspec node, with message arguments and contextMessages.
inherited
reportAtSourceRange(SourceRange sourceRange, {List<Object> arguments = const [], List<DiagnosticMessage>? contextMessages}) → Diagnostic
Reports a diagnostic at sourceRange, with message arguments and contextMessages.
inherited
reportAtToken(Token token, {List<Object> arguments = const [], List<DiagnosticMessage>? contextMessages}) → Diagnostic?
Reports a diagnostic at token, with message arguments and contextMessages.
inherited
runWithReporter(SaropaDiagnosticReporter reporter, SaropaContext context) → void
Override this method to implement your lint rule.
override
shouldSkipFile(String path) bool
Check if a file path should be skipped based on context settings.
inherited
toString() String
A string representation of this object.
inherited

Operators

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