showNiceIconPicker function
Future<IconData?>
showNiceIconPicker({
- required BuildContext context,
- IconData? selectedIcon,
- String title = 'Select Icon',
Show a modal icon picker dialog.
Returns the selected icon or null if cancelled.
final icon = await showNiceIconPicker(
context: context,
selectedIcon: currentIcon,
);
if (icon != null) {
setState(() => currentIcon = icon);
}
Implementation
Future<IconData?> showNiceIconPicker({
required BuildContext context,
IconData? selectedIcon,
String title = 'Select Icon',
}) async {
return showDialog<IconData>(
context: context,
builder: (ctx) {
return Dialog(
child: SizedBox(
width: 400,
height: 500,
child: Column(
children: [
Expanded(
child: NiceIconPicker(
selectedIcon: selectedIcon,
title: title,
onSelect: (icon) => Navigator.of(ctx).pop(icon),
),
),
Padding(
padding: const EdgeInsets.all(12),
child: Row(
mainAxisAlignment: MainAxisAlignment.end,
children: [
TextButton(
onPressed: () => Navigator.of(ctx).pop(),
child: const Text('Cancel'),
),
],
),
),
],
),
),
);
},
);
}