execute method
Executes this configuration.
The context
parameter provides access to the widget tree.
The optional arguments
map contains parameters for the execution.
Implementation
@override
FutureOr<void> execute(BuildContext context,
{Map<String, dynamic>? arguments}) {
final scaffoldState = Scaffold.maybeOf(context);
if (scaffoldState == null) {
VyuhBinding.instance.log
.debug('DrawerAction requires a Scaffold ancestor');
return null;
}
if (isEndDrawer == false && scaffoldState.hasDrawer == false) {
VyuhBinding.instance.log.debug(
'DrawerAction requires an drawer to be present in your Scaffold');
return null;
}
if (isEndDrawer && scaffoldState.hasEndDrawer == false) {
VyuhBinding.instance.log.debug(
'DrawerAction requires an endDrawer to be present in your Scaffold');
return null;
}
switch (actionType) {
case DrawerActionType.open:
if (isEndDrawer) {
scaffoldState.openEndDrawer();
} else {
scaffoldState.openDrawer();
}
break;
case DrawerActionType.close:
if (isEndDrawer) {
scaffoldState.openEndDrawer();
} else {
scaffoldState.openDrawer();
}
break;
}
}