move dropdwon list to cupertino picker
parent
9621f5d9b5
commit
0c23520318
@ -0,0 +1,59 @@
|
||||
import 'package:doctor_app_flutter/config/size_config.dart';
|
||||
import 'package:flutter/cupertino.dart';
|
||||
import 'package:flutter/material.dart';
|
||||
|
||||
/*
|
||||
*@author: Elham Rababah
|
||||
*@Date:12/4/2020
|
||||
*@param:
|
||||
*@return:
|
||||
*@desc: This class will contian some Function will help developer
|
||||
*/
|
||||
class Helpers {
|
||||
/*
|
||||
*@author: Elham Rababah
|
||||
*@Date:12/4/2020
|
||||
*@param: context, items, decKey, onSelectFun
|
||||
*@return: Container Widget
|
||||
*@desc: showCupertinoPicker its a general function to show cupertino picker
|
||||
*/
|
||||
showCupertinoPicker(context, items, decKey, onSelectFun) {
|
||||
showModalBottomSheet(
|
||||
context: context,
|
||||
builder: (BuildContext builder) {
|
||||
return Container(
|
||||
height: SizeConfig.realScreenHeight * .3,
|
||||
child: buildPickerItems(context, items, decKey, onSelectFun));
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
*@author: Elham Rababah
|
||||
*@Date:12/4/2020
|
||||
*@param: context, List items, decKey, onSelectFun
|
||||
*@return: Container widget
|
||||
*@desc: buildPickerIterm this function will build the items of the cupertino
|
||||
*/
|
||||
buildPickerItems(context, List items, decKey, onSelectFun) {
|
||||
return Container(
|
||||
child: CupertinoPicker(
|
||||
magnification: 1.5,
|
||||
// backgroundColor: Colors.black87,
|
||||
children: items.map((item) {
|
||||
return Text(
|
||||
'${item["$decKey"]}',
|
||||
style:
|
||||
TextStyle(color: Theme.of(context).primaryColor, fontSize: 20),
|
||||
);
|
||||
}).toList(),
|
||||
|
||||
itemExtent: 25, //height of each item
|
||||
looping: true,
|
||||
onSelectedItemChanged: (int index) {
|
||||
// selectitem =index;
|
||||
onSelectFun(index);
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue