StacMultiAction allows you to execute multiple actions with ease.
Multi Action Properties
| Property | Type | Description |
|---|---|---|
| actions | List<StacAction> | The list of actions to be performed |
| sync | bool | Whether to execute the actions in syncronous or parallel. Defaults to false. |
Example
This example will allow you to show a snackbar throughStacShowSnackBarAction, execute a network request through StacNetworkRequest and show another snackbar right after.
StacMultiAction(
sync: true,
actions: [
StacSnackBarAction(
content: StacText(data: 'Executing request...'),
action: StacSnackBarActionButton(
label: 'Done',
textColor: StacColors.blue,
onPressed: StacNoneAction(),
),
behavior: SnackBarBehavior.floating,
),
StacNetworkRequest(
url: 'https://example.com/api',
method: Method.get,
queryParameters: {'page': 1},
headers: {'Authorization': 'Bearer token'},
contentType: 'application/json',
body: {'data': 'example'},
results: [
StacNetworkResult(statusCode: 200, action: StacNoneAction()),
StacNetworkResult(statusCode: 404, action: StacNoneAction()),
],
),
StacSnackBarAction(
content: StacText(data: 'Request executed'),
action: StacSnackBarActionButton(
label: 'Done',
textColor: StacColors.blue,
onPressed: StacNoneAction(),
),
behavior: SnackBarBehavior.floating,
),
],
)
{
"actionType": "multiAction",
"sync": true,
"actions": [
{
"actionType": "showSnackBar",
"content": {
"type": "text",
"data": "Executing request..."
},
"action": {
"label": "Done",
"textColor": "#73C2FB",
"onPressed": {}
},
"behavior": "floating"
},
{
"actionType": "networkRequest",
"url": "https://example.com/api",
"method": "get",
"queryParameters": {
"page": 1
},
"headers": {
"Authorization": "Bearer token"
},
"contentType": "application/json",
"body": {
"data": "example"
},
"results": [
{
"statusCode": 200,
"action": {
"actionType": "none"
}
},
{
"statusCode": 404,
"action": {
"actionType": "none"
}
}
]
},
{
"actionType": "showSnackBar",
"content": {
"type": "text",
"data": "Request executed"
},
"action": {
"label": "Done",
"textColor": "#73C2FB",
"onPressed": {}
},
"behavior": "floating"
}
]
}