import 'package:flutter/material.dart'; import 'package:manager_app/constants.dart'; class DropDownInputContainer extends StatefulWidget { final String label; final List values; final String? initialValue; final ValueChanged? onChange; const DropDownInputContainer({ Key? key, required this.label, required this.values, this.initialValue, this.onChange, }) : super(key: key); @override _DropDownInputContainerState createState() => _DropDownInputContainerState(); } class _DropDownInputContainerState extends State { late String? selectedValue; @override void initState() { super.initState(); selectedValue = widget.initialValue; } @override Widget build(BuildContext context) { return Row( children: [ Align( alignment: AlignmentDirectional.centerStart, child: Text( widget.label, style: TextStyle(fontSize: 25, fontWeight: FontWeight.w300), ), ), Padding( padding: const EdgeInsets.all(8.0), child: DropdownButton( value: selectedValue, icon: const Icon(Icons.arrow_downward), iconSize: 24, elevation: 16, style: const TextStyle(color: Colors.black), underline: Container( height: 2, color: kPrimaryColor, ), onChanged: (String? newValue) { setState(() { selectedValue = newValue; widget.onChange!(selectedValue!); }); }, items: widget.values.map>((String value) { return DropdownMenuItem( value: value, child: Text( value, style: TextStyle(fontSize: 15), ), ); }).toList(), ), ), ], ); } }