You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
doctor_app_flutter/lib/util/helpers.dart

60 lines
1.6 KiB
Dart

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);
},
),
);
}
}