-
Notifications
You must be signed in to change notification settings - Fork 1
Description
@minkyn cloned issue escamoteur/flutter_command#22 on 2025-03-08:
According to the comment for
CommandResultclass:/// Combined execution state of a `Command` represented using four of its fields. /// A [CommandResult] will be issued for any state change of any of its fields /// During normal command execution you will get this items by listening at the command's [.results] ValueListenable. /// 1. If the command was just newly created you will get `param data, null, null, false` (paramData, data, error, isExecuting) /// 2. When calling execute: `param data, null, null, true` /// 3. When execution finishes: `param data, the result, null, false` /// `param data` is the data that you pass as parameter when calling the commandIn short, the way to tell whether a command has yet to execute or has completed execution is to see if
result.dataisnull.However, the actual implementation is inconsistent. The
result.dataalways returns the initial value set on command creation before executing. If the command returns the same value after execution, there is no way to tell them apart. Ideally,CommandResultshould have both a getter that returns the initial value before the actual data, as well as a getter that follows the comment to indicate a newly created command before execution.Moreover, even when
CommandResultwere fixed to follow its comments, for commands that have no return value, there is still no way to tell if execution has yet started, as theresult.datawill always be null before and after the execution.I know I can use another field to track that info, but it's not an elegant solution. The
Commandclass should embed that state internally, just like inFutureBuilderyou can usesnapshot.connectionStateto differentiateConnectionState.noneagainstConnectionState.done.