In Dart 3 instead of declaring the variable and then comparing you can simply write an if-case pattern:
if (value case final value?) {
// value is a fresh final variable
}