JsonPathApiConfiguration class final

Configuration for fetching and transforming API data using JSON Path.

Features:

  • HTTP request configuration (URL, headers, body)
  • JSON data extraction using JSON Path
  • Field mapping to card properties
  • List and single item handling
  • Error handling and fallbacks

Example:

final config = JsonPathApiConfiguration(
  url: 'https://api.example.com/items',
  headers: {'Authorization': 'Bearer token'},
  rootField: JSONPath('$.data.items'),
  fieldMap: DisplayFieldMap(
    title: JSONPath('$.name'),
    description: JSONPath('$.details'),
    imageUrl: JSONPath('$.image.url'),
  ),
);

The configuration will:

  • Fetch data from the specified URL
  • Extract items using the root field path
  • Map JSON fields to card properties
  • Handle both array and single object responses
  • Create a list of cards with consistent layout
Inheritance
Annotations
  • @JsonSerializable()

Constructors

JsonPathApiConfiguration.new({String? title, String url = '', Map<String, String>? headers, List<(String, String)>? requestBody, JSONPath rootField = const JSONPath(r'$'), DisplayFieldMap? fieldMap})
JsonPathApiConfiguration.fromJson(Map<String, dynamic> json)
factory

Properties

fieldMap DisplayFieldMap?
final
hashCode int
The hash code for this object.
no setterinherited
headers Map<String, String>?
final
requestBody List<(String, String)>?
final
rootField JSONPath
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
schemaType String
The schema type of the content item.
finalinherited
title String?
finalinherited
url String
final

Methods

build(BuildContext context, List<Card>? data) Widget
override
invoke(BuildContext context) Future<List<Card>?>
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited

Operators

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

Static Properties

typeDescriptor → TypeDescriptor<JsonPathApiConfiguration>
final

Constants

schemaName → const String