cpd_2022_zi/lib/widgets/drop_down.dart

31 lines
971 B
Dart
Raw Normal View History

2023-02-27 02:28:26 +01:00
import 'package:flutter/material.dart';
import 'package:provider/provider.dart';
import '../providers/input_provider.dart';
import '../providers/settings_provider.dart';
class DropDown extends StatelessWidget {
const DropDown({super.key});
@override
Widget build(BuildContext context) {
var inputModel = context.watch<InputProvider>();
var settings = context.watch<SettingsProvider>();
return DropdownButtonFormField<String>(
value: settings.settings?.relapseCategories?[0] ?? '',
icon: const Icon(Icons.arrow_downward),
elevation: 16,
style: const TextStyle(color: Colors.deepPurple),
onChanged: (String? value) {
inputModel.relapseCategory = value ?? '';
},
items: settings.settings?.relapseCategories
?.map<DropdownMenuItem<String>>((String value) {
return DropdownMenuItem<String>(
value: value,
child: Text(value),
);
}).toList(),
);
}
}