Skip to content

Commit 58e6f74

Browse files
committed
Add awesome dropdown example
1 parent 9cd4b21 commit 58e6f74

File tree

1 file changed

+145
-0
lines changed

1 file changed

+145
-0
lines changed
Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
1+
import 'package:flutter/material.dart';
2+
import 'package:searchfield/searchfield.dart';
3+
4+
class AwesomeDropdownExample extends StatefulWidget {
5+
const AwesomeDropdownExample({ Key? key }) : super(key: key);
6+
7+
@override
8+
_AwesomeDropdownExampleState createState() => _AwesomeDropdownExampleState();
9+
}
10+
11+
class _AwesomeDropdownExampleState extends State<AwesomeDropdownExample> {
12+
String? _selectedItem;
13+
14+
@override
15+
Widget build(BuildContext context) {
16+
return Scaffold(
17+
appBar: AppBar(
18+
elevation: 0,
19+
backgroundColor: Colors.white,
20+
title: const Text('@theflutterlover', style: TextStyle(
21+
color: Colors.black,
22+
),),
23+
),
24+
body: Container(
25+
child: Column(
26+
crossAxisAlignment: CrossAxisAlignment.start,
27+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
28+
children: [
29+
Container(
30+
height: MediaQuery.of(context).size.height * 0.7,
31+
child: Column(
32+
crossAxisAlignment: CrossAxisAlignment.start,
33+
mainAxisAlignment: MainAxisAlignment.center,
34+
children: [
35+
Padding(
36+
padding: EdgeInsets.all(20.0),
37+
child: Text('Select a country', style: TextStyle(
38+
fontSize: 16,
39+
color: Colors.blueGrey
40+
),),
41+
),
42+
Container(
43+
width: double.infinity,
44+
margin: EdgeInsets.symmetric(horizontal: 20),
45+
decoration: BoxDecoration(
46+
color: Colors.white,
47+
borderRadius: BorderRadius.circular(10),
48+
boxShadow: [
49+
BoxShadow(
50+
color: Colors.grey.withOpacity(0.2),
51+
blurRadius: 10,
52+
offset: Offset(0, 10),
53+
),
54+
],
55+
),
56+
child: SearchField(
57+
hint: 'Search',
58+
searchInputDecoration: InputDecoration(
59+
enabledBorder: OutlineInputBorder(
60+
borderSide: BorderSide(
61+
color: Colors.blueGrey.shade200,
62+
width: 1,
63+
),
64+
borderRadius: BorderRadius.circular(10),
65+
),
66+
focusedBorder: OutlineInputBorder(
67+
borderSide: BorderSide(
68+
width: 2,
69+
color: Colors.blue.withOpacity(0.8),
70+
),
71+
borderRadius: BorderRadius.circular(10),
72+
),
73+
),
74+
maxSuggestionsInViewPort: 6,
75+
itemHeight: 50,
76+
suggestionsDecoration: BoxDecoration(
77+
color: Colors.white,
78+
borderRadius: BorderRadius.circular(10),
79+
),
80+
onTap: (value) {
81+
setState(() {
82+
_selectedItem = value!;
83+
});
84+
85+
print(value);
86+
},
87+
suggestions: [
88+
'Afghanistan',
89+
'Turkey',
90+
'Germany',
91+
'France',
92+
'Italy',
93+
'Spain',
94+
'United Kingdom',
95+
'United States',
96+
'Canada',
97+
'Australia',
98+
'New Zealand',
99+
'India',
100+
'Indonesia',
101+
'Bangladesh',
102+
'Sri Lanka',
103+
],
104+
),
105+
),
106+
],
107+
),
108+
),
109+
Container(
110+
height: 90,
111+
padding: EdgeInsets.only(right: 20, left: 20, bottom: 20),
112+
decoration: BoxDecoration(
113+
color: Colors.white,
114+
),
115+
child: Row(
116+
mainAxisAlignment: MainAxisAlignment.spaceBetween,
117+
children: [
118+
_selectedItem == null ? Text('Please select a Country to Continue', style: TextStyle(
119+
fontSize: 16,
120+
color: Colors.blueGrey
121+
),) : Text(_selectedItem!, style: TextStyle(
122+
fontSize: 16,
123+
color: Colors.grey.shade800,
124+
fontWeight: FontWeight.w600
125+
)),
126+
MaterialButton(
127+
onPressed: () {},
128+
color: Colors.black,
129+
minWidth: 50,
130+
height: 50,
131+
shape: RoundedRectangleBorder(
132+
borderRadius: BorderRadius.circular(50),
133+
),
134+
padding: EdgeInsets.all(0),
135+
child: Icon(Icons.arrow_forward_ios, color: Colors.blueGrey, size: 24,),
136+
)
137+
],
138+
),
139+
)
140+
],
141+
),
142+
),
143+
);
144+
}
145+
}

0 commit comments

Comments
 (0)