isEnabled method
- ScrollIntent intent, [
- BuildContext? context
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.
The optional context
parameter is the context of the invocation of the
action, and in the case of an action invoked by a ShortcutManager, via
a Shortcuts widget, will be the context of the Shortcuts widget.
Implementation
@override
bool isEnabled(ScrollIntent intent, [BuildContext? context]) {
if (context == null) {
return false;
}
if (Scrollable.maybeOf(context) != null) {
return true;
}
final ScrollController? primaryScrollController = PrimaryScrollController.maybeOf(context);
return (primaryScrollController != null) && (primaryScrollController.hasClients);
}