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:
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:
const secondsPerHour = minutesPerHour * 60;
const minutesPerHour = 60;
Unless stated otherwise, the documentation on this site reflects Dart 3.7.3. Page last updated on 2025-05-08. View source or report an issue.