Skip to main content

Dropdown Custom

1

Image

import 'package:flutter/material.dart';
(String, Color) categoryChoosen = ('Adventure', Colors.green);
final categories = [
('Adventure', Colors.green),
('Mistery', Colors.amber),
('Action', Colors.blue),
('Romance', Colors.pink),
('Horror', Colors.red),
];
SubmenuButton(
menuStyle: MenuStyle(
shape: WidgetStatePropertyAll(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
),
),
maximumSize: const WidgetStatePropertyAll(
Size.fromHeight(200),
),
backgroundColor: const WidgetStatePropertyAll(
Colors.white,
),
padding: const WidgetStatePropertyAll(
EdgeInsets.symmetric(vertical: 10),
),
),
alignmentOffset: const Offset(0, 16),
style: ButtonStyle(
shape: WidgetStatePropertyAll(
RoundedRectangleBorder(
borderRadius: BorderRadius.circular(16),
side: const BorderSide(color: Colors.grey),
),
),
),
menuChildren: categories.map((e) {
return MenuItemButton(
onPressed: () {
categoryChoosen = e;
setState(() {});
},
style: const ButtonStyle(
padding: WidgetStatePropertyAll(
EdgeInsets.fromLTRB(16, 4, 24, 4),
),
),
leadingIcon: Icon(Icons.book, color: e.$2),
child: Text(
e.$1,
style: TextStyle(
fontWeight: FontWeight.w400,
fontSize: 18,
color: e.$2,
),
),
);
}).toList(),
leadingIcon: const Icon(Icons.book),
trailingIcon: const Icon(Icons.keyboard_arrow_down),
child: Text(categoryChoosen.$1),
),