XFileCapturedCallback typedef
XFileCapturedCallback =
bool Function(XFile, CameraPickerViewType)
The callback type definition when the XFile is captured by the camera. 拍摄文件生成后的回调
Return true
if it has handled arguments.
如果在回调中已经进行了处理,请返回 true
。
Future<void> _onXFileCaptured() async {
XFile? _fileToBeHandle;
await CameraPicker.pickFromCamera(
context,
pickerConfig: CameraPickerConfig(
onXFileCaptured: (XFile file, CameraPickerViewType viewType) {
// Pass the file out of the saving method's scope.
_fileToBeHandle = file;
// Pop twice without any result to exit the picker.
Navigator.of(context).pop();
},
),
);
// Continue your custom flow here.
print(_fileToBeHandle?.path);
}
Notice about the implementation
- After the callback is implemented and returned
true
, the default viewer page will not be presented anymore.
在实现时需要注意
- 实现了该方法且返回
true
后,默认的预览页面不会再出现。
Implementation
typedef XFileCapturedCallback = bool Function(XFile, CameraPickerViewType);