Skip to content

kIsWeb (and others) trigger non_bool_condition in default parameter value #53363

Description

@Bungeefan

I have a project that was completely valid in Dart 3.0.0 (up to 3.0.7) but produces analyzer issues with 3.1.0.
In Flutter words, this means 3.10.X works fine, 3.13 produces issues.

In short, the analyzer now starts complaining about the usage of a const bool (e.g. kIsWeb) in a const list in a default value of a constructor parameter. Yet, the project is still working and compiles/builds fine, even with Flutter 3.13.0.

The analyzer produces this "error":

Analyzing debug_overlay.dart...                                         

  error • Conditions must have a static type of 'bool' • lib/src/debug_overlay.dart:118:11 • non_bool_condition

1 issue found. (ran in 0.8s)

Using bool.fromEnvironment('dart.library.js_util') directly produces the same "error".

The code in question is available under https://github.com/Bungeefan/flutter_debug_overlay/blob/7169bded3afec112d83af2ea638d5078b29c3a22/lib/src/debug_overlay.dart#L105-L110

This happened without making any changes to the code. For example, pub.dev also started showing the same problem when using dart 3.1.0 for analysis.

Dart Info

General info

  • Dart 3.1.0 (stable) (Tue Aug 15 21:33:36 2023 +0000) on "linux_x64"
  • on linux / Linux 6.4.9-1-MANJARO # 1 SMP PREEMPT_DYNAMIC Wed Aug 9 08:32:12 UTC 2023
  • locale is de_AT.UTF-8

Project info

  • sdk constraint: '>=2.17.0 <4.0.0'
  • dependencies: collection, device_info_plus, dio, flutter, flutter_json, http, http_parser, multi_long_press_gesture_recognizer, package_info_plus, sliver_tools
  • dev_dependencies: flutter_lints, flutter_test

Process info

Memory CPU Elapsed time Command line
465 MB 87.7% 00:06 dart language-server --client-id=Android-Studio --client-version=AI-223.8836.35 --protocol=analyzer
75 MB 6.6% 00:06 flutter_tools.snapshot daemon

Metadata

Metadata

Assignees

No one assigned

    Labels

    P2A bug or feature request we're likely to work onanalyzer-constantslegacy-area-analyzerUse area-devexp instead.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