2022-09-06 15:40:49 +02:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
|
|
|
|
class CustomPopupMenu extends StatelessWidget {
|
|
|
|
const CustomPopupMenu({
|
|
|
|
Key? key,
|
|
|
|
required this.onSelected,
|
|
|
|
required this.children,
|
|
|
|
}) : super(key: key);
|
2023-01-30 13:35:06 +01:00
|
|
|
final Function(dynamic) onSelected;
|
|
|
|
final Map<int, Widget> children;
|
2022-09-06 15:40:49 +02:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
return Theme(
|
|
|
|
data: Theme.of(context).copyWith(useMaterial3: false),
|
|
|
|
child: PopupMenuButton<int>(
|
2022-09-07 13:20:13 +02:00
|
|
|
icon: Icon(
|
|
|
|
Icons.more_vert,
|
|
|
|
color: Theme.of(context).colorScheme.secondary,
|
|
|
|
),
|
2022-09-06 15:40:49 +02:00
|
|
|
onSelected: onSelected,
|
|
|
|
itemBuilder: (context) => children.entries
|
|
|
|
.map(
|
|
|
|
(entry) => PopupMenuItem<int>(
|
|
|
|
padding: const EdgeInsets.all(16.0).copyWith(right: 20),
|
|
|
|
value: entry.key,
|
|
|
|
child: entry.value,
|
|
|
|
),
|
|
|
|
)
|
|
|
|
.toList(),
|
|
|
|
shape: RoundedRectangleBorder(
|
|
|
|
borderRadius: BorderRadius.circular(24),
|
|
|
|
),
|
|
|
|
color: Theme.of(context).colorScheme.secondaryContainer,
|
|
|
|
position: PopupMenuPosition.under,
|
|
|
|
),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|