showPicker method
void
showPicker({
- CallbackData? callback,
- CameraType type = CameraType.full,
- bool isPopView = true,
inherited
Implementation
void showPicker(
{CallbackData? callback,
CameraType type = CameraType.full,
bool isPopView = true}) async {
switch (type) {
case CameraType.camera:
XFile? image = await _imgFromCamera();
if (callback != null) {
callback(image?.path);
}
// Navigator.of(context).pop();
break;
case CameraType.photo:
XFile? image = await _imgFromGallery();
if (callback != null) {
callback(image?.path);
}
// Navigator.of(context).pop();
break;
case CameraType.full:
showModalBottomSheet(
context: context,
builder: (BuildContext bc) {
return SafeArea(
child: Wrap(
children: <Widget>[
ListTile(
leading: const Icon(Icons.photo_library),
title: Text('photogallery'.tr,
style: const TextStyle(fontSize: fontSize15)),
onTap: () async {
XFile? image = await _imgFromGallery();
// ignore: use_build_context_synchronously
Navigator.of(context).pop();
if (callback != null && image != null) {
callback(image.path);
}
}),
ListTile(
leading: const Icon(Icons.photo_camera),
title: Text('camera'.tr,
style: const TextStyle(fontSize: fontSize15)),
onTap: () async {
XFile? image = await _imgFromCamera();
// ignore: use_build_context_synchronously
Navigator.of(context).pop();
if (callback != null && image != null) {
callback(image.path);
}
},
),
],
),
);
});
break;
default:
}
}