invoke method

  1. @override
Future<List<Card>?> invoke(
  1. BuildContext context
)
override

Implementation

@override
Future<List<vf.Card>?> invoke(BuildContext context) async {
  final response = await vyuh.network.get(Uri.parse(url));
  final json = jsonDecode(response.body);

  final rootItem = JsonPath(rootField.path).read(json);
  if (rootItem.singleOrNull == null) return null;

  final root = rootItem.single.value;

  return switch (root) {
    List() => root.map((e) => _createCard(e)).toList(),
    Map() => [_createCard(root as Map<String, dynamic>)],
    _ => null
  };
}