import 'package:flutter/material.dart'; import 'package:provider/provider.dart'; import '../providers/input_provider.dart'; class DropDown extends StatelessWidget { final List _items; const DropDown(this._items, {super.key}); @override Widget build(BuildContext context) { var inputModel = context.watch(); inputModel.relapseCategory = _items.isNotEmpty ? _items[0] : ''; return DropdownButtonFormField( value: _items.isEmpty ? null : _items[0], icon: const Icon(Icons.arrow_downward), elevation: 16, onChanged: (String? value) { inputModel.relapseCategory = value ?? ''; }, items: _items.map>((String value) { return DropdownMenuItem( value: value, child: Text(value), ); }).toList(), ); } }