import 'package:flutter/material.dart'; import 'package:manager_api_new/api.dart'; import 'package:manager_app/constants.dart'; class SingleChoiceInputContainer extends StatelessWidget { final String label; final T? selected; final List values; final ValueChanged onChanged; final double borderRadius; final Color selectedColor; final Color textColor; const SingleChoiceInputContainer({ Key? key, required this.label, required this.selected, required this.values, required this.onChanged, this.borderRadius = 12, this.selectedColor = kPrimaryColor, this.textColor = kWhite, }) : super(key: key); @override Widget build(BuildContext context) { return FormField( initialValue: selected, builder: (state) { return InputDecorator( decoration: InputDecoration( labelText: label, border: OutlineInputBorder( borderRadius: BorderRadius.circular(borderRadius), ), contentPadding: const EdgeInsets.symmetric(horizontal: 25, vertical: 20), ), child: DropdownButtonHideUnderline( child: DropdownButton( value: selected, isExpanded: true, // todo handle view items: values.map((v) { return DropdownMenuItem( value: v, child: Row( children: [ Text((v as SectionEventDTO).label ?? ""), // TODO Update to handle more types ! ], ), ); }).toList(), onChanged: (value) { if (value != null) { onChanged(value); state.didChange(value); } }, ), ), ); }, ); } }