processTableData method
void
processTableData()
Implementation
void processTableData() {
try {
// Parse the JSON string
dynamic data = json.decode(widget.tableData);
// Check if the parsed data is a List
if (data is List && data.isNotEmpty) {
if (data[0] is Map<String, dynamic>) {
tableData = List<Map<String, dynamic>>.from(data);
} else {
throw const FormatException('Unexpected data format');
}
} else {
throw const FormatException('Data is not a non-empty list');
}
if (tableData.isNotEmpty) {
dataSource = TableDataSource(tableData: tableData);
}
setState(() {
isLoading = false;
});
} catch (e) {
print('Error processing table data: $e');
setState(() {
isLoading = false;
});
}
}