Skip to content

invariant_booleans false positive with while #57535

Closed
@zoechi

Description

@zoechi

image

  Future<Null> pageChanged(int newPage) async {
    if (newPage - 1 == currentPage) {
      return;
    }
    if (newPage - 1 > currentPage) {
      while (newPage - 1 > currentPage) {
        await nextPage();
      }
    } else {
      while (newPage - 1 < currentPage) {
        await previousPage();
      }
    }
  }

await nextPage() updates currentPage, therefore this will eventually evaluate to true

Metadata

Metadata

Assignees

Labels

P4devexp-linterIssues with the analyzer's support for the linter packagelegacy-area-analyzerUse area-devexp instead.linter-false-positiveIssues related to lint rules that report a problem when it isn't a problem.type-bugIncorrect behavior (everything from a crash to more subtle misbehavior)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions