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;
Was this page's content helpful?
Thank you for your feedback!
Provide details Thank you for your feedback! Please let us know what we can do to improve.
Provide details Unless stated otherwise, the documentation on this site reflects Dart 3.8.1. Page last updated on 2025-05-08. View source or report an issue.