|
| 1 | +import 'package:flutter/material.dart'; |
| 2 | + |
| 3 | +class GFDropdown<T> extends StatefulWidget { |
| 4 | + GFDropdown( |
| 5 | + {Key key, |
| 6 | + @required this.items, |
| 7 | + this.menuitems, |
| 8 | + this.icon, |
| 9 | + this.selectedItemBuilder, |
| 10 | + this.value, |
| 11 | + this.hint, |
| 12 | + this.disabledHint, |
| 13 | + @required this.onChanged, |
| 14 | + this.onTap, |
| 15 | + this.elevation = 8, |
| 16 | + this.style, |
| 17 | + this.underline, |
| 18 | + this.iconDisabledColor, |
| 19 | + this.iconEnabledColor, |
| 20 | + this.iconSize = 24.0, |
| 21 | + this.isDense = false, |
| 22 | + this.isExpanded = false, |
| 23 | + this.itemHeight = kMinInteractiveDimension, |
| 24 | + this.focusColor, |
| 25 | + this.focusNode, |
| 26 | + this.autofocus = false, |
| 27 | + this.dropdownColor, |
| 28 | + this.padding = const EdgeInsets.all(5), |
| 29 | + this.borderRadius = const BorderRadius.all(Radius.circular(4)), |
| 30 | + this.borderColor}); |
| 31 | + |
| 32 | + DropdownButtonBuilder selectedItemBuilder; |
| 33 | + final List<DropdownMenuItem<T>> items; |
| 34 | + final List<DropdownMenuItem<T>> menuitems; |
| 35 | + |
| 36 | + final Widget icon; |
| 37 | + final int elevation; |
| 38 | + final T value; |
| 39 | + final Color borderColor; |
| 40 | + final EdgeInsets padding; |
| 41 | + |
| 42 | + final Widget hint; |
| 43 | + final Widget disabledHint; |
| 44 | + final ValueChanged<T> onChanged; |
| 45 | + |
| 46 | + final VoidCallback onTap; |
| 47 | + final TextStyle style; |
| 48 | + |
| 49 | + final Widget underline; |
| 50 | + |
| 51 | + final Color iconDisabledColor; |
| 52 | + |
| 53 | + final Color iconEnabledColor; |
| 54 | + |
| 55 | + final double iconSize; |
| 56 | + |
| 57 | + final bool isDense; |
| 58 | + |
| 59 | + final bool isExpanded; |
| 60 | + |
| 61 | + final double itemHeight; |
| 62 | + |
| 63 | + final Color focusColor; |
| 64 | + |
| 65 | + final FocusNode focusNode; |
| 66 | + |
| 67 | + final bool autofocus; |
| 68 | + |
| 69 | + final Color dropdownColor; |
| 70 | + |
| 71 | + final BorderRadius borderRadius; |
| 72 | + |
| 73 | + @override |
| 74 | + _GFDropdownState createState() => _GFDropdownState(); |
| 75 | +} |
| 76 | + |
| 77 | +class _GFDropdownState extends State<GFDropdown> { |
| 78 | + @override |
| 79 | + Widget build(BuildContext context) { |
| 80 | + return Container( |
| 81 | + padding: widget.padding, |
| 82 | + decoration: BoxDecoration( |
| 83 | + borderRadius: widget.borderRadius, |
| 84 | + border: Border.all( |
| 85 | + color: widget.borderColor != null |
| 86 | + ? widget.borderColor |
| 87 | + : Colors.white)), |
| 88 | + child: DropdownButton( |
| 89 | + items: widget.items, |
| 90 | + selectedItemBuilder: widget.selectedItemBuilder, |
| 91 | + value: widget.value, |
| 92 | + hint: widget.hint, |
| 93 | + disabledHint: widget.disabledHint, |
| 94 | + onChanged: widget.onChanged == null ? null : widget.onChanged, |
| 95 | + onTap: widget.onTap, |
| 96 | + elevation: widget.elevation, |
| 97 | + style: widget.style, |
| 98 | + icon: widget.icon, |
| 99 | + iconDisabledColor: widget.iconDisabledColor, |
| 100 | + iconEnabledColor: widget.iconEnabledColor, |
| 101 | + iconSize: widget.iconSize, |
| 102 | + isDense: widget.isDense, |
| 103 | + isExpanded: widget.isExpanded, |
| 104 | + itemHeight: widget.itemHeight, |
| 105 | + focusColor: widget.focusColor, |
| 106 | + focusNode: widget.focusNode, |
| 107 | + autofocus: widget.autofocus, |
| 108 | + dropdownColor: widget.dropdownColor, |
| 109 | + )); |
| 110 | + } |
| 111 | + |
| 112 | + // Widget menuitem() { |
| 113 | + // final List<ListItem> items; |
| 114 | + |
| 115 | + // List:['bcdncjs', 'cniskdcmdk']; |
| 116 | + // return Container( |
| 117 | + // child:Text('j') |
| 118 | + |
| 119 | + // } |
| 120 | +} |
0 commit comments