In Dart 2.0, it will become a compile-time error to try to perform a
function invocation on a variable whose static type is Object (see
https://github.com/dart-lang/sdk/issues/31509). Since value is
changed inside the if block, it is not type promoted, so its type is
considered to be Object. Therefore, to avoid a compile-time error,
we need to use an intermediate variable of type Function.
In Dart 2.0, it will become a compile-time error to try to perform a function invocation on a variable whose static type is
Object
(see https://github.com/dart-lang/sdk/issues/31509). Sincevalue
is changed inside theif
block, it is not type promoted, so its type is considered to beObject
. Therefore, to avoid a compile-time error, we need to use an intermediate variable of type Function.