Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When I press the shared button it calls onPrinted instead of onShared #1647

Open
juliandambrosio opened this issue Apr 19, 2024 · 2 comments
Labels
bug Something isn't working needs triage

Comments

@juliandambrosio
Copy link

juliandambrosio commented Apr 19, 2024

Describe the bug
PdfPreview
if (widget.useActions && widget.allowSharing && info?.canShare == true) {
actions.add(PdfShareAction(
filename: widget.pdfFileName,
onShared:
widget.onPrinted == null ? null : () => widget.onPrinted!(context),
));
}

To Reproduce
return PdfPreview(
build: (format) => _buildPdfDocument(credential, image, format).save(),
allowSharing: true,
allowPrinting: true,
pageFormats: defaultPageFormats,
canChangeOrientation: false,
canDebug: false,
dpi: 72,
initialPageFormat: _getInitialPageFormat(credential),
pdfFileName: '${credential.fileName}.pdf',
onPrinted: (BuildContext context) async {
NavigatorService.pushReplacementNamed(HomeScreen.routeName);
},
onPrintError: (BuildContext context, dynamic error) async {
NavigatorService.pushReplacementNamed(HomeScreen.routeName);
});
}

When I press the shared button it calls onPrinted instead of onShared

Expected behavior
Custom onShared is never used, but must be called

@juliandambrosio juliandambrosio added bug Something isn't working needs triage labels Apr 19, 2024
@juliandambrosio juliandambrosio changed the title OnShared call widget.onPrinted function When I press the shared button it calls onPrinted instead of onShared Apr 19, 2024
@bksbora
Copy link

bksbora commented May 24, 2024

onShared: widget.onPrinted == null ? null : () => widget.onPrinted!(context),

you pressed onShared but you called onPrinted, so it's normal. Sorry , i couldn't understand. Can you explain more ?

@juliandambrosio
Copy link
Author

onShared: widget.onPrinted == null ? null : () => widget.onPrinted!(context),

you pressed onShared but you called onPrinted, so it's normal. Sorry , i couldn't understand. Can you explain more ?

I think this function should be called when I press the shared button.

/// Called if the user shares the pdf document
final void Function(BuildContext context)? onShared;

But in both cases, this other function is called when I print or share a PDF.
/// Called if the user prints the pdf document
final void Function(BuildContext context)? onPrinted;

These functions are found in the pdf_preview.dart file

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working needs triage
Projects
None yet
Development

No branches or pull requests

2 participants