Skip to content

Commit 96322c0

Browse files
committed
single drop down is in progress with testing
1 parent 1ce3a16 commit 96322c0

File tree

6 files changed

+699
-66
lines changed

6 files changed

+699
-66
lines changed

example/lib/main.dart

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,70 @@ class Textf extends StatefulWidget {
2020
}
2121

2222
class _TextfState extends State<Textf> {
23+
int _value = 1;
2324
@override
2425
Widget build(BuildContext context) {
2526
return Scaffold(
26-
body: GFTextField(
27-
decoration:
28-
InputDecoration(border: InputBorder.none, hintText: 'bujnm'),
27+
body: Row(children: [
28+
Expanded(
29+
child: Container(
30+
margin: EdgeInsets.only(top: 70, left: 30, right: 30),
31+
child: GFDropdown(
32+
items: [],
33+
dropdownColor: Colors.red,
34+
value: _value,
35+
isExpanded: true,
36+
borderColor: Colors.blueGrey,
37+
padding: EdgeInsets.all(0),
38+
icon: Icon(Icons.home),
39+
isDense: true,
40+
borderRadius: BorderRadius.only(
41+
topLeft: Radius.circular(20),
42+
bottomRight: Radius.circular(20)),
43+
onChanged: (value) {
44+
setState(() {
45+
_value = value;
46+
});
47+
}),
48+
),
2949
),
30-
);
50+
Expanded(
51+
child: Container(
52+
margin: EdgeInsets.only(top: 70, left: 30, right: 30),
53+
child: DropdownButton(
54+
dropdownColor: Colors.red,
55+
value: _value,
56+
style: TextStyle(color: Colors.blue),
57+
iconEnabledColor: Colors.amber,
58+
iconDisabledColor: Colors.blueGrey,
59+
hint: Text('kijijm'),
60+
disabledHint: Text('cfgvhjn'),
61+
elevation: 4,
62+
autofocus: true,
63+
focusColor: Colors.orange,
64+
isExpanded: false,
65+
underline: Text('bjnmk'),
66+
isDense: true,
67+
iconSize: 50,
68+
icon: Icon(Icons.home),
69+
items: [
70+
DropdownMenuItem(
71+
child: Text("First s"),
72+
value: 1,
73+
),
74+
DropdownMenuItem(
75+
child: Text("Second"),
76+
value: 2,
77+
),
78+
],
79+
onChanged: (value) {
80+
setState(() {
81+
_value = value;
82+
});
83+
}),
84+
),
85+
)
86+
]));
3187
}
3288
}
3389

Lines changed: 120 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,120 @@
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

Comments
 (0)