StacNetworkRequest class
A Stac action that performs HTTP network requests.
This action makes HTTP requests to specified URLs and can execute different actions based on the response status code using results. Supports all common HTTP methods (GET, POST, PUT, DELETE) and allows customization of headers, query parameters, and request body.
{@tool snippet} Dart Example:
const StacNetworkRequest(
url: 'https://api.example.com/users',
method: Method.post,
headers: {'Authorization': 'Bearer token123'},
body: {'name': 'John', 'email': 'john@example.com'},
results: [
StacNetworkResult(
statusCode: 200,
action: {'type': 'navigate', 'routeName': '/success'}
),
StacNetworkResult(
statusCode: 400,
action: {'type': 'showSnackBar', 'message': 'Invalid data'}
),
],
)
{@end-tool}
{@tool snippet} JSON Example:
{
"type": "networkRequest",
"url": "https://api.example.com/users",
"method": "post",
"headers": {"Authorization": "Bearer token123"},
"body": {"name": "John", "email": "john@example.com"},
"results": [
{
"statusCode": 200,
"action": {"type": "navigate", "routeName": "/success"}
},
{
"statusCode": 400,
"action": {"type": "showSnackBar", "message": "Invalid data"}
}
]
}
{@end-tool}
- Inheritance
-
- Object
- StacAction
- StacNetworkRequest
- Available extensions
- Annotations
-
- @JsonSerializable.new()
Constructors
-
StacNetworkRequest({required String url, Method method = Method.get, Map<
String, dynamic> ? queryParameters, Map<String, dynamic> ? headers, String? contentType, dynamic body, List<StacNetworkResult> results = const []}) -
Creates a StacNetworkRequest to perform an HTTP call.
const
-
StacNetworkRequest.fromJson(Map<
String, dynamic> json) -
Creates a StacNetworkRequest from a JSON map.
factory
Properties
- actionType → String
-
Action type identifier.
no setteroverride
- body → dynamic
-
The request payload. Can be a map, list, string, or bytes depending on encoder.
final
- contentType → String?
-
The Content-Type header value (e.g.,
application/json).final - hashCode → int
-
The hash code for this object.
no setterinherited
-
headers
→ Map<
String, dynamic> ? -
Optional request headers.
final
-
jsonData
→ Map<
String, dynamic> ? -
The raw JSON data associated with this action.
finalinherited
- method → Method
-
The HTTP method to use. Defaults to Method.get.
final
-
queryParameters
→ Map<
String, dynamic> ? -
Optional key-value pairs appended to the URL as query parameters.
final
-
results
→ List<
StacNetworkResult> -
List of conditional results that map a response status code to an action.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- url → String
-
The absolute or relative URL to request.
final
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
parse(
BuildContext context) → FutureOr -
Available on StacAction?, provided by the StacActionParserExtension extension
-
toJson(
) → Map< String, dynamic> -
Converts this StacNetworkRequest instance to a JSON map.
override
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited