import 'package:flutter/material.dart'; /// Settings row with a trailing [DropdownButton]. Each option renders as an /// icon + label row; the currently selected option is disabled in the menu, /// matching the settings styling. [onChanged] receives the picked (non-null) /// value. class SettingsDropdownTile extends StatelessWidget { final IconData icon; final String title; final T value; final List options; final IconData Function(T) optionIcon; final String Function(T) optionLabel; final ValueChanged onChanged; const SettingsDropdownTile({ required this.icon, required this.title, required this.value, required this.options, required this.optionIcon, required this.optionLabel, required this.onChanged, super.key, }); @override Widget build(BuildContext context) { return ListTile( leading: Icon(icon), title: Text(title), trailing: DropdownButton( value: value, icon: const Icon(Icons.arrow_drop_down), items: options .map( (e) => DropdownMenuItem( value: e, enabled: e != value, child: Row( children: [ Icon(optionIcon(e)), const SizedBox(width: 10), Text(optionLabel(e)), ], ), ), ) .toList(), onChanged: (e) { if (e != null) onChanged(e); }, ), ); } }