mirror of
https://github.com/foss42/apidash.git
synced 2025-05-22 00:36:43 +08:00
83 lines
2.4 KiB
Dart
83 lines
2.4 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:apidash/utils/utils.dart';
|
|
import 'package:apidash/consts.dart';
|
|
|
|
class MapTable extends StatelessWidget {
|
|
const MapTable(
|
|
{super.key,
|
|
required this.map,
|
|
required this.colNames,
|
|
this.firstColumnHeaderCase = false});
|
|
|
|
final Map map;
|
|
final List<String> colNames;
|
|
final bool firstColumnHeaderCase;
|
|
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Table(
|
|
border: TableBorder(
|
|
horizontalInside: BorderSide(
|
|
color: Theme.of(context).colorScheme.surfaceContainerHighest,
|
|
),
|
|
),
|
|
columnWidths: const <int, TableColumnWidth>{
|
|
0: FlexColumnWidth(),
|
|
1: FlexColumnWidth(),
|
|
},
|
|
defaultVerticalAlignment: TableCellVerticalAlignment.middle,
|
|
children: [
|
|
TableRow(
|
|
children: colNames
|
|
.map<TableCell>(
|
|
(e) => TableCell(
|
|
verticalAlignment: TableCellVerticalAlignment.top,
|
|
child: Padding(
|
|
padding: kP1,
|
|
child: SelectableText(
|
|
e,
|
|
style: kCodeStyle.copyWith(
|
|
fontWeight: FontWeight.bold,
|
|
color: Theme.of(context).colorScheme.primary,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
)
|
|
.toList(),
|
|
),
|
|
...map.entries.map<TableRow>(
|
|
(entry) => TableRow(
|
|
children: [
|
|
TableCell(
|
|
verticalAlignment: TableCellVerticalAlignment.top,
|
|
child: Padding(
|
|
padding: kP1,
|
|
child: SelectableText(
|
|
firstColumnHeaderCase
|
|
? formatHeaderCase(entry.key)
|
|
: entry.key,
|
|
style: kCodeStyle.copyWith(
|
|
color: Theme.of(context).colorScheme.tertiary,
|
|
),
|
|
),
|
|
),
|
|
),
|
|
TableCell(
|
|
verticalAlignment: TableCellVerticalAlignment.top,
|
|
child: Padding(
|
|
padding: kP1,
|
|
child: SelectableText(
|
|
entry.value,
|
|
style: kCodeStyle,
|
|
),
|
|
),
|
|
),
|
|
],
|
|
),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|