import 'package:flutter/material.dart';
import 'package:webproject/res/param.dart';
class DropDownCategory extends StatefulWidget {
final String name;
Function function;
String chose;
List<String> list;
DropDownCategory({Key key,
this.name, this.list, this.chose, this.function})
: super(key: key);
@override _DropDownCategoryState createState() => _DropDownCategoryState();
}
class _DropDownCategoryState extends State<DropDownCategory> {
bool f = true;
String getItem() {
return widget.chose;
}
@override Widget build(BuildContext context) {
return Container(
child: Row(
children: [
Text(
widget.name,
style: tsBolt,
),
Container(
padding: EdgeInsets.symmetric(horizontal: 15),
decoration: BoxDecoration(
color: Colors.white12,
border: Border.all(width: 3, color: Colors.orangeAccent),
borderRadius: BorderRadius.circular(20)),
child: DropdownButton<String>(
focusColor: Colors.orangeAccent,
value: widget.chose,
hint: Text(
widget.chose,
style: tsBolt,
),
items:
widget.list.map((String value) {
return new DropdownMenuItem<String>(
value: value,
child: Container(
child: Text(
value,
style: TextStyle(fontWeight: FontWeight.bold),
),
),
);
}).toList(),
onChanged: (String Value) {
setState(() {
widget.chose = Value;
print(widget.chose + " drop");
widget.function();
});
},
),
),
],
));
}
}