2023-02-27 02:28:26 +01:00
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
import 'package:provider/provider.dart';
|
|
|
|
import '../providers/input_provider.dart';
|
|
|
|
|
|
|
|
class DropDown extends StatelessWidget {
|
2023-02-27 02:35:17 +01:00
|
|
|
final List<String> _items;
|
|
|
|
const DropDown(this._items, {super.key});
|
2023-02-27 02:28:26 +01:00
|
|
|
|
|
|
|
@override
|
|
|
|
Widget build(BuildContext context) {
|
|
|
|
var inputModel = context.watch<InputProvider>();
|
|
|
|
return DropdownButtonFormField<String>(
|
2023-02-27 11:07:46 +01:00
|
|
|
value: _items.isEmpty ? null : _items[0],
|
2023-02-27 02:28:26 +01:00
|
|
|
icon: const Icon(Icons.arrow_downward),
|
|
|
|
elevation: 16,
|
|
|
|
onChanged: (String? value) {
|
|
|
|
inputModel.relapseCategory = value ?? '';
|
|
|
|
},
|
2023-02-27 02:35:17 +01:00
|
|
|
items: _items.map<DropdownMenuItem<String>>((String value) {
|
2023-02-27 02:28:26 +01:00
|
|
|
return DropdownMenuItem<String>(
|
|
|
|
value: value,
|
|
|
|
child: Text(value),
|
|
|
|
);
|
|
|
|
}).toList(),
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|