Files
Hirameki-SRS/lib/src/widgets/options_grid.dart
Rene Kievits ba82e662f6 v1
2025-10-27 18:52:16 +01:00

53 lines
1.4 KiB
Dart

import 'package:flutter/material.dart';
class OptionsGrid extends StatelessWidget {
final List<String> options;
final void Function(String) onSelected;
final Color? buttonColor;
final Color? textColor;
const OptionsGrid({
super.key,
required this.options,
required this.onSelected,
this.buttonColor,
this.textColor,
});
@override
Widget build(BuildContext context) {
if (options.isEmpty) return const SizedBox.shrink();
final theme = Theme.of(context);
final bg = buttonColor ?? theme.colorScheme.primary;
final fg = textColor ?? theme.colorScheme.onPrimary;
return Wrap(
spacing: 10,
runSpacing: 10,
alignment: WrapAlignment.center,
children: options.map((o) {
return SizedBox(
width: 160,
child: ElevatedButton(
onPressed: () => onSelected(o),
style: ElevatedButton.styleFrom(
backgroundColor: bg,
foregroundColor: fg,
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
padding: const EdgeInsets.symmetric(vertical: 16, horizontal: 8),
),
child: Text(
o,
style: TextStyle(fontSize: 20, color: fg),
textAlign: TextAlign.center,
),
),
);
}).toList(),
);
}
}