import 'package:flutter/material.dart'; import 'package:shadcn_ui/shadcn_ui.dart'; /// ShadTable.list를 감싼 공통 테이블 래퍼. class SuperportTable extends StatelessWidget { const SuperportTable({ super.key, required this.columns, required this.rows, this.columnSpanExtent, this.rowHeight = 56, this.onRowTap, this.emptyLabel = '데이터가 없습니다.', }); final List columns; final List> rows; final TableSpanExtent? Function(int index)? columnSpanExtent; final double rowHeight; final void Function(int index)? onRowTap; final String emptyLabel; @override Widget build(BuildContext context) { if (rows.isEmpty) { final theme = ShadTheme.of(context); return Padding( padding: const EdgeInsets.all(32), child: Center( child: Text(emptyLabel, style: theme.textTheme.muted), ), ); } final tableRows = [ for (final row in rows) row .map( (cell) => cell is ShadTableCell ? cell : ShadTableCell(child: cell), ) .toList(), ]; return ShadTable.list( header: columns .map( (cell) => cell is ShadTableCell ? cell : ShadTableCell.header(child: cell), ) .toList(), columnSpanExtent: columnSpanExtent, rowSpanExtent: (_) => FixedTableSpanExtent(rowHeight), onRowTap: onRowTap, children: tableRows, ); } }