Skip to content

Commit 60a82a3

Browse files
committed
2 parents a61b81e + 16dd4d0 commit 60a82a3

File tree

12 files changed

+1060
-271
lines changed

12 files changed

+1060
-271
lines changed

.idea/libraries/Dart_Packages.xml

Lines changed: 116 additions & 100 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/libraries/Dart_SDK.xml

Lines changed: 19 additions & 11 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.idea/workspace.xml

Lines changed: 411 additions & 50 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,18 @@ dropdown_menu: ^1.1.0
2525
## Build custom menu
2626

2727

28+
29+
# How to use
30+
31+
```
32+
33+
34+
```
35+
36+
2837
## Examples
2938

3039
>see[main.dart](https://github.com/jzoom/flutter_dropdown_menu/blob/master/example/lib/main.dart)
3140
3241

42+

example/lib/basic_menu.dart

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
import 'package:flutter/material.dart';
3+
4+
class BasicMenu extends StatefulWidget{
5+
@override
6+
State<StatefulWidget> createState() {
7+
return new _BasicMenuState();
8+
}
9+
10+
}
11+
12+
class _BasicMenuState extends State<BasicMenu>{
13+
@override
14+
Widget build(BuildContext context) {
15+
return new Container(
16+
17+
);
18+
}
19+
20+
}

example/lib/config.dart

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
2+
import 'dart:convert';
3+
4+
const List<Map<String, dynamic>> ORDERS = [
5+
{"title": "综合排序"},
6+
{"title": "好评优先"},
7+
{"title": "离我最近"},
8+
{"title": "人气最高"},
9+
];
10+
11+
const int ORDER_INDEX = 0;
12+
13+
const List<Map<String, dynamic>> TYPES = [
14+
{"title": "全部", "id": 0},
15+
{"title": "甜点饮品", "id": 1},
16+
{"title": "生日蛋糕", "id": 2},
17+
{"title": "火锅", "id": 3},
18+
{"title": "自助餐", "id": 4},
19+
{"title": "小吃", "id": 5},
20+
{"title": "快餐", "id": 6},
21+
{"title": "日韩料理", "id": 7},
22+
{"title": "西餐", "id": 8},
23+
{"title": "聚餐", "id": 9},
24+
{"title": "烧烤", "id": 10},
25+
{"title": "川菜", "id": 11},
26+
{"title": "江浙菜", "id": 12},
27+
{"title": "东北菜", "id": 13},
28+
{"title": "蒙餐", "id": 14},
29+
{"title": "新疆菜", "id": 15},
30+
];
31+
32+
const int TYPE_INDEX = 2;
33+
34+
const List<Map<String, dynamic>> BUSINESS_CYCLE = [
35+
{
36+
"title": "附近",
37+
"children": [
38+
{"title": "附近", "distance": 500},
39+
{"title": "1km", "distance": 1000},
40+
{"title": "2km", "distance": 2000}
41+
]
42+
},
43+
{
44+
"title": "推荐商圈",
45+
"children": [
46+
{"title": "中山路", "count": 326},
47+
{"title": "万达广场", "count": 100},
48+
{"title": "瑞景", "count": 50}
49+
]
50+
},
51+
{
52+
"title": "附近",
53+
"children": [
54+
{"title": "附近", "distance": 500},
55+
{"title": "1km", "distance": 1000},
56+
{"title": "2km", "distance": 2000}
57+
]
58+
},
59+
{
60+
"title": "附近",
61+
"children": [
62+
{"title": "附近", "distance": 500},
63+
{"title": "1km", "distance": 1000},
64+
{"title": "2km", "distance": 2000}
65+
]
66+
},
67+
];
68+
69+
String FOOD_JSON =
70+
'[{"title":"力体","children":[{"title":"传声织","count":810},{"title":"分队什","count":463},{"title":"且工","count":325},{"title":"清局","count":899},{"title":"代老克","count":325},{"title":"持连回","count":14},{"title":"改层听","count":470},{"title":"存比","count":908},{"title":"热土米","count":333},{"title":"水发","count":58},{"title":"制见","count":28},{"title":"取化无","count":469},{"title":"记有何","count":503},{"title":"亲公何","count":930},{"title":"步业要","count":885}]},{"title":"建易外","children":[{"title":"生观真","count":207},{"title":"音代","count":425},{"title":"族王资","count":205},{"title":"圆传统","count":791},{"title":"些任","count":141},{"title":"程即走","count":163},{"title":"各七","count":65},{"title":"院此格","count":314},{"title":"支及","count":726},{"title":"别题","count":524},{"title":"低去到","count":706},{"title":"般将","count":13},{"title":"西南","count":189},{"title":"状南制","count":335},{"title":"调油","count":90},{"title":"听从没","count":33},{"title":"电求什","count":88}]},{"title":"非先算","children":[{"title":"严状","count":108},{"title":"查增","count":634},{"title":"号备","count":304},{"title":"法口群","count":304},{"title":"半电报","count":324},{"title":"线红","count":153},{"title":"信证作","count":546},{"title":"器电","count":651},{"title":"示南称","count":128},{"title":"全战","count":412},{"title":"走打","count":592},{"title":"眼基般","count":134},{"title":"来究计","count":322},{"title":"性们","count":511},{"title":"儿数金","count":427},{"title":"已计","count":593},{"title":"导养","count":973}]},{"title":"头走认","children":[{"title":"导时","count":229},{"title":"达积且","count":277},{"title":"样队儿","count":592},{"title":"电历","count":568},{"title":"车一","count":618},{"title":"求生研","count":886},{"title":"正将","count":300},{"title":"并米论","count":945},{"title":"压进到","count":320},{"title":"具候素","count":607},{"title":"它长","count":411},{"title":"写非","count":716},{"title":"实员产","count":452},{"title":"资参管","count":561},{"title":"八主","count":748},{"title":"事厂要","count":672},{"title":"命面","count":83},{"title":"任天","count":106}]},{"title":"机列二","children":[{"title":"展花","count":426},{"title":"经报导","count":363},{"title":"分带完","count":767},{"title":"于却安","count":687},{"title":"她回别","count":520},{"title":"根层性","count":853},{"title":"历感","count":532},{"title":"大响三","count":573},{"title":"本住","count":893},{"title":"际志","count":466},{"title":"温金起","count":231},{"title":"山温","count":910},{"title":"把程","count":463},{"title":"出交认","count":232}]},{"title":"其造据","children":[{"title":"满成风","count":49},{"title":"正世龙","count":385},{"title":"命出","count":142},{"title":"真区","count":736},{"title":"压平马","count":780},{"title":"交飞省","count":876},{"title":"集处就","count":694},{"title":"车便","count":410},{"title":"样装性","count":713},{"title":"斯更","count":425},{"title":"响许","count":975},{"title":"能目设","count":778},{"title":"近准","count":974},{"title":"参音","count":252},{"title":"教见","count":611},{"title":"问素","count":883},{"title":"连也","count":265},{"title":"飞采","count":448},{"title":"法那且","count":748},{"title":"区决门","count":173}]},{"title":"东么","children":[{"title":"近华","count":875},{"title":"极何现","count":576},{"title":"叫条等","count":501},{"title":"办市","count":344},{"title":"无组便","count":177},{"title":"义料","count":728},{"title":"声米","count":743},{"title":"进论书","count":670},{"title":"土九","count":339},{"title":"山矿","count":560},{"title":"一参","count":303}]},{"title":"老农","children":[{"title":"总计工","count":667},{"title":"验义风","count":456},{"title":"业导低","count":802},{"title":"音速是","count":26},{"title":"器众","count":869},{"title":"争才","count":775},{"title":"面听三","count":635},{"title":"拉后","count":293},{"title":"也按","count":339},{"title":"没式其","count":673},{"title":"酸细","count":405},{"title":"平后","count":302},{"title":"给气","count":269},{"title":"持后","count":864},{"title":"月次","count":561},{"title":"一者","count":36},{"title":"名问当","count":600},{"title":"马该","count":785},{"title":"为列","count":915}]},{"title":"局点自","children":[{"title":"什深求","count":399},{"title":"时么","count":514},{"title":"果放北","count":638},{"title":"导片","count":622},{"title":"第该打","count":353},{"title":"队深决","count":526},{"title":"器低县","count":626},{"title":"花正不","count":98},{"title":"难要江","count":111},{"title":"质市","count":241},{"title":"快强又","count":429},{"title":"细与","count":624},{"title":"证厂","count":922},{"title":"新调业","count":302},{"title":"开圆","count":35}]},{"title":"近从","children":[{"title":"改然","count":396},{"title":"受为","count":17},{"title":"受口","count":262},{"title":"与全大","count":25},{"title":"拉总","count":149},{"title":"代打题","count":171},{"title":"主造出","count":163},{"title":"最交能","count":922},{"title":"高五","count":786},{"title":"开革","count":12},{"title":"名情","count":990},{"title":"级油","count":818},{"title":"温办始","count":431},{"title":"济地节","count":330},{"title":"象龙","count":233}]}]';
71+
72+
List FOODS = json.decode(FOOD_JSON);
73+
74+
75+
const int FOOD_INDEX = 1;

example/lib/fix_menu.dart

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
//
2+
//DropdownMenu buildDropdownMenu() {
3+
// return new DropdownMenu(maxMenuHeight: kDropdownMenuItemHeight * 10,
4+
// // activeIndex: activeIndex,
5+
// menus: [
6+
// new DropdownMenuBuilder(
7+
// builder: (BuildContext context) {
8+
// return new DropdownListMenu(
9+
// selectedIndex: TYPE_INDEX,
10+
// data: TYPES,
11+
// itemBuilder: buildCheckItem,
12+
// );
13+
// },
14+
// height: kDropdownMenuItemHeight * TYPES.length),
15+
// new DropdownMenuBuilder(
16+
// builder: (BuildContext context) {
17+
// return new DropdownListMenu(
18+
// selectedIndex: ORDER_INDEX,
19+
// data: ORDERS,
20+
// itemBuilder: buildCheckItem,
21+
// );
22+
// },
23+
// height: kDropdownMenuItemHeight * ORDERS.length),
24+
// new DropdownMenuBuilder(builder: (BuildContext context) {
25+
// return new DropdownTreeMenu(
26+
// selectedIndex: 0,
27+
// subSelectedIndex: 0,
28+
// itemExtent: 45.0,
29+
// background: Colors.red,
30+
// subBackground: Colors.blueAccent,
31+
// itemBuilder: (BuildContext context, dynamic data, bool selected) {
32+
// if (!selected) {
33+
// return new DecoratedBox(
34+
// decoration: new BoxDecoration(
35+
// border: new Border(
36+
// right: Divider.createBorderSide(context))),
37+
// child: new Padding(
38+
// padding: const EdgeInsets.only(left: 15.0),
39+
// child: new Row(
40+
// children: <Widget>[
41+
// new Text(data['title']),
42+
// ],
43+
// )));
44+
// } else {
45+
// return new DecoratedBox(
46+
// decoration: new BoxDecoration(
47+
// border: new Border(
48+
// top: Divider.createBorderSide(context),
49+
// bottom: Divider.createBorderSide(context))),
50+
// child: new Container(
51+
// color: Theme.of(context).scaffoldBackgroundColor,
52+
// child: new Row(
53+
// children: <Widget>[
54+
// new Container(
55+
// color: Theme.of(context).primaryColor,
56+
// width: 3.0,
57+
// height: 20.0),
58+
// new Padding(
59+
// padding: new EdgeInsets.only(left: 12.0),
60+
// child: new Text(data['title'])),
61+
// ],
62+
// )));
63+
// }
64+
// },
65+
// subItemBuilder:
66+
// (BuildContext context, dynamic data, bool selected) {
67+
// Color color = selected
68+
// ? Theme.of(context).primaryColor
69+
// : Theme.of(context).textTheme.body1.color;
70+
//
71+
// return new SizedBox(
72+
// height: 45.0,
73+
// child: new Row(
74+
// children: <Widget>[
75+
// new Text(
76+
// data['title'],
77+
// style: new TextStyle(color: color),
78+
// ),
79+
// new Expanded(
80+
// child: new Align(
81+
// alignment: Alignment.centerRight,
82+
// child: new Text(data['count'].toString())))
83+
// ],
84+
// ),
85+
// );
86+
// },
87+
// getSubData: (dynamic data) {
88+
// return data['children'];
89+
// },
90+
// data: FOODS,
91+
//
92+
// );
93+
// },height: 450.0)
94+
// ]);
95+
//}
96+
//
97+
//DropdownHeader buildDropdownHeader({DropdownMenuHeadTapCallback onTap}) {
98+
// return new DropdownHeader(
99+
// onTap: onTap,
100+
// titles: [TYPES[TYPE_INDEX], ORDERS[ORDER_INDEX], FOODS[0]['children'][0]],
101+
// );
102+
//}
103+
//
104+
//Widget buildFixHeaderDropdownMenu() {
105+
// return new DefaultDropdownMenuController(
106+
// child: new Column(
107+
// children: <Widget>[
108+
// buildDropdownHeader(),
109+
// new Expanded(
110+
// child: new Stack(
111+
// children: <Widget>[
112+
// new ListView(
113+
// children: <Widget>[new Text("123123")],
114+
// ),
115+
// buildDropdownMenu()
116+
// ],
117+
// ))
118+
// ],
119+
// ));
120+
//}
121+
//
122+
//Widget buildInnerListHeaderDropdownMenu() {
123+
// return new DefaultDropdownMenuController(
124+
// onSelected: ({int menuIndex, int index, int subIndex, dynamic data}) {
125+
// print(
126+
// "menuIndex:$menuIndex index:$index subIndex:$subIndex data:$data");
127+
// },
128+
// child: new Stack(
129+
// children: <Widget>[
130+
// new CustomScrollView(
131+
// controller: scrollController,
132+
// slivers: <Widget>[
133+
// new SliverList(
134+
// key: globalKey,
135+
// delegate: new SliverChildBuilderDelegate(
136+
// (BuildContext context, int index) {
137+
// return new Container(
138+
// color: Colors.black26,
139+
// child: new Image.asset(
140+
// "images/header.jpg",
141+
// fit: BoxFit.fill,
142+
// ),
143+
// );
144+
// }, childCount: 1)),
145+
// new SliverPersistentHeader(
146+
// delegate: new DropdownSliverChildBuilderDelegate(
147+
// builder: (BuildContext context) {
148+
// return new Container(
149+
// color: Theme.of(context).scaffoldBackgroundColor,
150+
// child: buildDropdownHeader(onTap: this._onTapHead));
151+
// }),
152+
// pinned: true,
153+
// floating: true,
154+
// ),
155+
// new SliverList(
156+
// delegate: new SliverChildBuilderDelegate(
157+
// (BuildContext context, int index) {
158+
// return new Container(
159+
// color: Theme.of(context).scaffoldBackgroundColor,
160+
// child: new Image.asset(
161+
// "images/body.jpg",
162+
// fit: BoxFit.fill,
163+
// ),
164+
// );
165+
// }, childCount: 10)),
166+
// ]),
167+
// new Padding(
168+
// padding: new EdgeInsets.only(top: 46.0),
169+
// child: buildDropdownMenu())
170+
// ],
171+
// ));
172+
//}
173+
//
174+
//GlobalKey globalKey;
175+
//
176+
//void _onTapHead(int index) {
177+
// RenderObject renderObject = globalKey.currentContext.findRenderObject();
178+
// DropdownMenuController controller =
179+
// DefaultDropdownMenuController.of(globalKey.currentContext);
180+
// //
181+
// scrollController
182+
// .animateTo(scrollController.offset + renderObject.semanticBounds.height,
183+
// duration: new Duration(milliseconds: 150), curve: Curves.ease)
184+
// .whenComplete(() {
185+
// controller.show(index);
186+
// });
187+
//}
188+
189+
190+
import 'package:flutter/material.dart';
191+
192+
class FixMenu extends StatefulWidget{
193+
@override
194+
State<StatefulWidget> createState() {
195+
return new _FixMenuState();
196+
}
197+
198+
}
199+
200+
class _FixMenuState extends State<FixMenu>{
201+
@override
202+
Widget build(BuildContext context) {
203+
return new Container(
204+
205+
);
206+
}
207+
208+
}

example/lib/header_menu.dart

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
2+
import 'package:flutter/material.dart';
3+
4+
class HeaderMenu extends StatefulWidget{
5+
@override
6+
State<StatefulWidget> createState() {
7+
return new _HeaderMenuState();
8+
}
9+
10+
}
11+
12+
class _HeaderMenuState extends State<HeaderMenu>{
13+
@override
14+
Widget build(BuildContext context) {
15+
return new Container(
16+
17+
);
18+
}
19+
20+
}

0 commit comments

Comments
 (0)