53 lines
1.5 KiB
Dart
53 lines
1.5 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:gap/gap.dart';
|
|
import 'package:google_fonts/google_fonts.dart';
|
|
|
|
typedef OnChangedCallback = void Function(dynamic value);
|
|
|
|
class DropDownWidget extends StatelessWidget {
|
|
final String label;
|
|
final List list;
|
|
final String listTitle;
|
|
final OnChangedCallback onChanged;
|
|
|
|
const DropDownWidget({
|
|
super.key,
|
|
required this.label,
|
|
required this.list,
|
|
required this.listTitle,
|
|
required this.onChanged,
|
|
});
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
return Column(
|
|
crossAxisAlignment: CrossAxisAlignment.start,
|
|
children: [
|
|
Text(
|
|
'$label:',
|
|
style: GoogleFonts.outfit(
|
|
textStyle: const TextStyle(color: Colors.white, fontSize: 16),
|
|
),
|
|
),
|
|
const Gap(8),
|
|
Container(
|
|
decoration: BoxDecoration(
|
|
borderRadius: BorderRadius.circular(10), // Set the desired border radius
|
|
border: Border.all(color: Colors.white), // Set the border color
|
|
),
|
|
child: DropdownMenu(
|
|
initialSelection: '',
|
|
dropdownMenuEntries: [
|
|
for (var item in list)
|
|
DropdownMenuEntry(
|
|
label: item[listTitle].toString(),
|
|
value: item[listTitle],
|
|
)
|
|
],
|
|
onSelected: onChanged,
|
|
width: MediaQuery.of(context).size.width,
|
|
textStyle: GoogleFonts.outfit(textStyle: TextStyle(color: Colors.white))),
|
|
),
|
|
],
|
|
);
|
|
}
|
|
}
|