Loading...
Loading...
Use ShadSelect for dropdown option lists; ShadOption, placeholder, selectedOptionBuilder, scrollable groups, ShadSelect.withSearch, ShadSelect.multiple, ShadSelectFormField. Use when adding dropdowns, single/multi select, or searchable select in a Flutter shadcn_ui app.
npx skill4agent add serverpod/skills-registry shadcn_ui-selectShadSelect<T>optionsShadOption<T>PaddingplaceholderselectedOptionBuilder: (context, value) => ...onChangedinitialValueminWidthmaxWidthmaxHeightShadSelectFormField<T>idvalidatorallowDeselection: truefinal fruits = {'apple': 'Apple', 'banana': 'Banana', ...};
ShadSelect<String>(
placeholder: const Text('Select a fruit'),
options: [
Padding(
padding: const EdgeInsets.symmetric(horizontal: 8, vertical: 6),
child: Text(
'Fruits',
style: theme.textTheme.muted.copyWith(
fontWeight: FontWeight.w600,
color: theme.colorScheme.popoverForeground,
),
textAlign: TextAlign.start,
),
),
...fruits.entries.map((e) => ShadOption(value: e.key, child: Text(e.value))),
],
selectedOptionBuilder: (context, value) => Text(fruits[value]!),
onChanged: print,
)ShadSelectFormField<String>(
id: 'email',
minWidth: 350,
initialValue: null,
options: verifiedEmails
.map((email) => ShadOption(value: email, child: Text(email)))
.toList(),
selectedOptionBuilder: (context, value) =>
value == 'none' ? const Text('Select a verified email to display') : Text(value),
placeholder: const Text('Select a verified email to display'),
validator: (v) {
if (v == null) return 'Please select an email to display';
return null;
},
)ShadSelect.withSearchonSearchChangedsearchPlaceholderOffstage(offstage: !filtered.containsKey(key), child: ShadOption(...))ShadSelect.multipleselectedOptionsBuilder: (context, values) => ...onChangedallowDeselection: truecloseOnSelect: false