# admin_dropdown.dart
{{tag>flutter admin downdown}}
import 'package:app_screen_flutter/view/admin/home/atom/border_text.dart';
import 'package:flutter/material.dart';
class AdminDropdown extends StatelessWidget {
const AdminDropdown({
super.key,
this.width = 500,
this.title = "",
required this.value,
required this.items,
required this.onChanged,
required this.itemBuilder,
});
final String title;
final double width;
final T? value;
final List items;
final Function(T?) onChanged;
final Function(T) itemBuilder;
@override
Widget build(BuildContext context) {
return SizedBox(
width: width,
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
BorderText(title, border: true),
const SizedBox(width: 10),
DropdownButton(
value: value,
items: items
.map((T e) => DropdownMenuItem(
value: e,
child: itemBuilder(e),
))
.toList(),
onChanged: onChanged,
)
],
),
);
}
}
## import
- [[border_text.dart]]
## 호출
AdminDropdown(
title: 'service',
value: controller.service.value,
items: ServiceService.to.serviceList,
itemBuilder: (Service e) => Text(e.name),
onChanged: (Service? e) {
if (e != null) controller.selectService(e);
},
),