getJsonDataById method

dynamic getJsonDataById(
  1. String? id
)

get jsonData from document that has id named id if not throw Exception.

Implementation

getJsonDataById(String? id) {
  if (id?.isEmpty ?? true) return jsonData;
  final data = document?.getElementById(id!)?.innerHtml;
  if (data == null) {
    throw Exception("invalid json id: $id");
  }
  return jsonDecode(data);
}