Files
sf-app-platform/packages/design_system/lib/src/dropdowns/dropdown.dart
AlcalaJulian a64a9a2a32 fixes
2025-12-04 10:45:10 +01:00

77 lines
2.0 KiB
Dart

import 'package:flutter/material.dart';
class CustomDropdown extends StatelessWidget {
final List<Widget> items;
final List<dynamic>? values;
final ValueChanged<dynamic> onChanged;
final dynamic value;
final String? hint;
final String? label;
final double radius;
final double height;
final double width;
final Color? color;
const CustomDropdown({
super.key,
required this.items,
this.values,
required this.onChanged,
this.value,
this.hint,
this.label,
this.radius = 12,
this.width = double.infinity,
this.height = 70,
this.color,
});
@override
Widget build(BuildContext context) {
return Column(
spacing: 8,
children: [
if (label != null)
Align(
alignment: Alignment.bottomLeft,
child: Text(
label!,
style: const TextStyle(fontSize: 14, letterSpacing: 0),
),
),
SizedBox(
width: width,
height: height,
child: Center(
child: DropdownButtonFormField<dynamic>(
dropdownColor: Colors.white,
decoration: InputDecoration(
enabledBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(radius)),
borderSide: BorderSide(
color: color ?? const Color(0xFF4B4B4B),
),
),
),
initialValue: value,
onChanged: onChanged,
hint: hint != null ? Text(hint!) : null,
items: List<DropdownMenuItem<dynamic>>.generate(items.length, (
int index,
) {
final dynamic itemValue = values != null
? values![index]
: index;
return DropdownMenuItem<dynamic>(
value: itemValue,
child: items[index],
);
}),
),
),
),
],
);
}
}