isEnabled method Null safety
- ScrollIntent intent
override
Returns true if the action is enabled and is ready to be invoked.
This will be called by the ActionDispatcher before attempting to invoke the action.
Implementation
@override
bool isEnabled(ScrollIntent intent) {
final FocusNode? focus = primaryFocus;
final bool contextIsValid = focus != null && focus.context != null;
if (contextIsValid) {
// Check for primary scrollable within the current context
if (Scrollable.of(focus.context!) != null) {
return true;
}
// Check for fallback scrollable with context from PrimaryScrollController
final ScrollController? primaryScrollController = PrimaryScrollController.of(focus.context!);
return primaryScrollController != null && primaryScrollController.hasClients;
}
return false;
}