StacDynamicView class

A Stac model for dynamically fetching data and rendering it using a template.

This widget makes a network request based on the request configuration. The fetched data, potentially targeted by targetPath, is then used to render the template. The full response can be stored in the Stac context using resultTarget. It also supports custom widgets for loaderWidget, emptyTemplate (if data is empty), and errorWidget states.

StacDynamicView(
  request: StacNetworkRequest(url: 'https://api.example.com/data'),
  template: StacText(data: 'Name: \${data.name}'), // Example: template uses data binding
  targetPath: 'items', // Path to the list within the response
  resultTarget: 'apiData', // Where to store the full response in context
  loaderWidget: StacCircularProgressIndicator(),
  emptyTemplate: StacText(data: 'No items found.'),
)
{
  "type": "dynamicView",
  "request": {
    "url": "https://api.example.com/data",
    "method": "GET"
  },
  "template": {
    "type": "text",
    "data": "Name: \${data.name}"
  },
  "targetPath": "items",
  "resultTarget": "apiData",
  "loaderWidget": {
    "type": "circularProgressIndicator"
  },
  "emptyTemplate": {
    "type": "text",
    "data": "No items found."
  }
}
Inheritance
Annotations
  • @JsonSerializable()

Constructors

StacDynamicView.new({required StacNetworkRequest request, StacWidget? template, String? targetPath, String? resultTarget, StacWidget? emptyTemplate, StacWidget? loaderWidget, StacWidget? errorWidget})
Creates a StacDynamicView with the given properties.
const
StacDynamicView.fromJson(Map<String, dynamic> json)
Creates a StacDynamicView from a JSON map.
factory

Properties

emptyTemplate StacWidget?
Optional StacWidget to display if the fetched data is empty or null.
final
errorWidget StacWidget?
Optional StacWidget to display if the network request fails.
final
hashCode int
The hash code for this object.
no setterinherited
jsonData Map<String, dynamic>?
Raw JSON data for this widget
finalinherited
loaderWidget StacWidget?
Optional StacWidget to display while the network request is in progress.
final
request StacNetworkRequest
Configuration for the network request to fetch data.
final
resultTarget String?
Path in the Stac context where the full JSON response will be stored.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
targetPath String?
Path within the fetched JSON data to find the actual content to be rendered.
final
template StacWidget?
The StacWidget template used to render the fetched data.
final
type String
Widget type identifier.
no setteroverride

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toJson() Map<String, dynamic>
Converts this StacDynamicView instance to a JSON map.
override
toString() String
A string representation of this object.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited