recursive_compile_time_constant
The compile-time constant expression depends on itself.
Description
#The analyzer produces this diagnostic when the value of a compile-time constant is defined in terms of itself, either directly or indirectly, creating an infinite loop.
Example
#The following code produces this diagnostic twice because both of the constants are defined in terms of the other:
dart
const secondsPerHour = minutesPerHour * 60;
const minutesPerHour = secondsPerHour / 60;
Common fixes
#Break the cycle by finding an alternative way of defining at least one of the constants:
dart
const secondsPerHour = minutesPerHour * 60;
const minutesPerHour = 60;
除非另有说明,文档之所提及适用于 Dart 3.7.3 版本,本页面最后更新时间: 2025-05-08。 查看文档源码 或者 报告页面问题。