TableController.fromJson constructor

TableController.fromJson(
  1. Map<String, dynamic> json, {
  2. void onScroll(
    1. double scrollTop,
    2. double scrollHeight,
    3. double clientHeight
    )?,
})

Create from JSON (convenience factory)

Implementation

factory TableController.fromJson(
  Map<String, dynamic> json, {
  void Function(double scrollTop, double scrollHeight, double clientHeight)? onScroll,
}) {
  // Handle nested visualResponse structure
  final configJson = json.containsKey('visualResponse')
      ? json['visualResponse'] as Map<String, dynamic>
      : json;

  // Create config from JSON
  final baseConfig = TableConfig.fromJson(configJson);

  final data = (json['tableValues'] as List?)
          ?.whereType<Map<String, dynamic>>()
          .toList() ??
      [];

  return TableController(config: baseConfig, data: data)..onScroll = onScroll;
}