click static method

Future click(
  1. GlobalKey<State<StatefulWidget>> key, {
  2. String fileName = 'davinci',
  3. required BuildContext context,
  4. bool openFilePreview = true,
  5. bool saveToDevice = false,
  6. String? albumName,
  7. double? pixelRatio,
  8. 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);
  }
}