click static method
Future
click(
- GlobalKey<
State< key, {StatefulWidget> > - String fileName = 'davinci',
- required BuildContext context,
- bool openFilePreview = true,
- bool saveToDevice = false,
- String? albumName,
- double? pixelRatio,
- bool returnImageUint8List = false,
If the widget is in the widget tree, use this method. if the fileName is not set, it sets the file name as "davinci". you can define whether to openFilePreview or returnImageUint8List openFilePreview is true by default. Context is required.
Implementation
static Future click(GlobalKey key,
{String fileName = 'davinci',
required BuildContext context,
bool openFilePreview = true,
bool saveToDevice = false,
String? albumName,
double? pixelRatio,
bool returnImageUint8List = false}) async {
try {
pixelRatio ??= View.of(context).devicePixelRatio;
// finding the widget in the current context by the key.
RenderRepaintBoundary repaintBoundary =
key.currentContext!.findRenderObject() as RenderRepaintBoundary;
/// With the repaintBoundary we got from the context, we start the createImageProcess
return await _createImageProcess(
albumName: albumName,
source: _Source.click,
fileName: fileName,
saveToDevice: saveToDevice,
returnImageUint8List: returnImageUint8List,
openFilePreview: openFilePreview,
repaintBoundary: repaintBoundary,
pixelRatio: pixelRatio,
);
} catch (e) {
/// if the above process is failed, the error is printed.
print(e);
}
}