You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Actions.find et.al should return Action<Intent> instead of Action<T>. #180871
In the Action<T extends Intent> class the type parameter T is contravariant since an instance of Action<Intent> should be able to handle any Intent. But currently it means the opposite: an Action<Intent> can handle Intent, but not any Intent subtypes. This is a problem for find but not invoke.
expected behavior:
finalclassMyIntentextendsIntent {}
// Put this widget in the tree.Actions(
actions:const {
MyIntent:DoNothingAction(),
},
child: ...
),
// Able to find the intent final intent =Actions.find<Intent>(context, intent: intent);
Actual behavior:
crashes because currently Actions.find returns Action<T>. We are able to find Action<U> where T :< U (and verify that in debug mode), but casting the Action<U> to Action<T> would result in a runtime crash.
Activity
loic-sharma commentedon Jan 13, 2026
@LongCatIsLooong would another option be to deprecate
maybeFindandfindin favor of new methods with return typeAction<Intent>?Potential names for the new methods:
Actions.of, maybe acceptable since this does establish a dependencyActions.lookupActions.getFix some type checks in the `Actions` widget (flutter#180883)