Skip to content

Commit

Permalink
feat(add city picker demo):
Browse files Browse the repository at this point in the history
  • Loading branch information
hanxu317317 committed Feb 5, 2019
1 parent 53a7d71 commit 63b9dc6
Show file tree
Hide file tree
Showing 5 changed files with 58 additions and 5 deletions.
Binary file modified assets/app.db
Binary file not shown.
29 changes: 26 additions & 3 deletions lib/widgets/components/Pick/CityPIcker/demo.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,37 @@
//

import 'package:flutter/material.dart';
import 'package:city_pickers/city_pickers.dart';

class Demo extends StatefulWidget {
class CityPickerDemo extends StatefulWidget {
_Demo createState() => _Demo();
}

class _Demo extends State<Demo> {
class _Demo extends State<CityPickerDemo> {
String _result;
show(context) async {
Result temp = await CityPickers.showCityPicker(
context: context,
// locationCode: '640221',
height: 400,
);
setState(() {
_result = "${temp.toString()}";
});
}

Widget build(BuildContext context) {
return Container();
return Center(
child: Column(
children: <Widget>[
Text("result: ${_result.toString()}"),
RaisedButton(
onPressed: () {this.show(context);
},
child: Text("select"),
),
],
)
);
}
}
26 changes: 24 additions & 2 deletions lib/widgets/components/Pick/CityPIcker/index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,36 @@
//

import 'package:flutter/material.dart';

import 'package:flutter_go/components/widget_demo.dart';
import 'demo.dart';
const String content0 = '''
### **简介**
> 显示中国的省市县地区
通过函数 **showCityPicker** 调用, 在容器窗口上弹出遮罩层
''';
const String content1 = '''
### **基本用法**
- locationCode 初始化地区选择
- height 弹出层高度
- context 上下文对象
''';
class Demo extends StatefulWidget {
static const String routeName = '/components/Pick/CityPicker';
_Demo createState() => _Demo();
}

class _Demo extends State<Demo> {

Widget build(BuildContext context) {
return Container();
return WidgetDemo(
title: 'CityPicker',
codeUrl: '',
docUrl: '',
contentList: [
content0,
content1,
CityPickerDemo()
],
);
}
}
7 changes: 7 additions & 0 deletions lib/widgets/components/Pick/index.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import 'YearPicker/index.dart' as YearPicker;
import 'DayPicker/index.dart' as DayPicker;
import 'MonthPicker/index.dart' as MonthPicker;
import 'ShowdatePicker/index.dart' as ShowdatePicker;
import 'CityPIcker/index.dart' as CityPicker;

List<WidgetPoint> widgetPoints = [
WidgetPoint(
Expand All @@ -27,4 +28,10 @@ List<WidgetPoint> widgetPoints = [
routerName: ShowdatePicker.Demo.routeName,
buildRouter: (BuildContext context) => ShowdatePicker.Demo(),
),
WidgetPoint(
name: 'CityPicker',
routerName: CityPicker.Demo.routeName,
buildRouter: (BuildContext context) => CityPicker.Demo(),
),

];
1 change: 1 addition & 0 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ dependencies:
flutter_webview_plugin: ^0.3.0+2
# 日期格式化
intl: 0.15.7
city_pickers: ^0.1.0

dev_dependencies:
flutter_test:
Expand Down

0 comments on commit 63b9dc6

Please sign in to comment.