wmhpicker 0.0.4 wmhpicker: ^0.0.4 copied to clipboard
Custom pickerView.
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:wmhpicker/wmhpicker.dart';
import 'package:flutter/cupertino.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Welcome to Flutter',
debugShowCheckedModeBanner: false,
home: homeApp(),
);
}
}
class homeApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<homeApp> {
bool showView = false;
String _platformVersion = 'Unknown';
List<Map> tempData = [
{'subDatas' : ['明天','今天','后天']},
{'subDatas' : ['不想','想','要']},
{'subDatas' : ['去吃饭','去玩','去打游戏']},
];
@override
void initState() {
super.initState();
initPlatformState();
}
// Platform messages are asynchronous, so we initialize in an async method.
Future<void> initPlatformState() async {
String platformVersion;
// Platform messages may fail, so we use a try/catch PlatformException.
try {
platformVersion = await Wmhpicker.platformVersion;
} on PlatformException {
platformVersion = 'Failed to get platform version.';
}
// If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling
// setState to update our non-existent appearance.
if (!mounted) return;
setState(() {
// _platformVersion = platformVersion;
});
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('Plugin example app'),
),
body: GestureDetector(
child: Container(
width: 100,
height: 100,
color: Colors.red,
),
onTap: () {
showView = true;
showDialog<Null>(
context: context, //BuildContext对象
barrierDismissible: false,
builder: (BuildContext context) {
return WMHPickerView(showPicker: true, pickerData: this.tempData, callBack: (item) {
print('haha' + item.toString());
showView = false;
setState(() {
});
}, cancelBtnColor: Colors.black,
confirmBtnColor: Colors.black,
pickerBackgroundColor: Colors.white,
pickerTextColor: Colors.black,
textSize: 20.0,pickerHeight: 300,
isDatePicker: false,
minYear: 1994,
maxYear: 2019);
});
},
),
),
);
}
}