import 'package:flutter/material.dart'; import 'package:forui/forui.dart'; class SettingSelect extends StatelessWidget { final T? value; final List options; final String Function(T value) labelOf; final ValueChanged? onChanged; final bool enabled; const SettingSelect({ super.key, required this.value, required this.options, required this.labelOf, required this.onChanged, this.enabled = true, }); @override Widget build(BuildContext context) { final screenWidth = MediaQuery.maybeSizeOf(context)?.width; final maxWidth = screenWidth == null ? 240.0 : (screenWidth * 0.45).clamp(120.0, 240.0).toDouble(); return ConstrainedBox( constraints: BoxConstraints(minWidth: 96, maxWidth: maxWidth), child: FSelect.rich( enabled: enabled && onChanged != null, control: FSelectControl.lifted( value: value, onChange: onChanged ?? (_) {}, ), format: labelOf, children: [ for (final option in options) FSelectItem.item(title: Text(labelOf(option)), value: option), ], ), ); } }