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