joseph-grabinger / flutter_to_pdf

Create PDFs but work with normal Flutter Widgets.
MIT License
21 stars 17 forks source link

Cast Error on trying to create page #75

Closed RenatoCesarF closed 4 months ago

RenatoCesarF commented 4 months ago

Hi, I''m trying to export a complex page, but always receive some of those errors:

My flutter version: Flutter 3.19.4 • channel stable • https://github.com/flutter/flutter.git Framework • revision 68bfaea224 (4 months ago) • 2024-03-20 15:36:31 -0700 Engine • revision a5c24f538d Tools • Dart 3.3.2 • DevTools 2.31.1

I tried export just a simple Widget and it works, but not all my page or a more complex one.

Don't know if its the package version, the flutter version or some configuration.

Follows more of my code:

    ExportFrame(
                exportDelegate: controller.exporter,
                frameId: 'analytics',
                child: Widget(...))
  @action
  Future<void> export(BuildContext context) async {
    try {
      final pdf = await exporter.exportToPdfDocument('analytics');
      await saveFile(pdf, 'teste');
      SuccessMessage.show(
          context, "Feedback enviado com sucesso! Muito Obrigado");
    } catch (e, stackTrace) {
      print(stackTrace);
      print(e);
      ErrorMessage.show(context, e.toString());
    }
  }
  ExportDelegate exporter = ExportDelegate(
      options: const ExportOptions(
    checkboxOptions: CheckboxOptions.none(),
    pageFormatOptions: PageFormatOptions.a4(),
  ));
sousa-p commented 4 months ago

I had the same error, I tried this solution:

PR: https://github.com/joseph-grabinger/flutter_to_pdf/pull/77

joseph-grabinger commented 4 months ago

I had the same error, I tried this solution:

PR: https://github.com/joseph-grabinger/flutter_to_pdf/pull/77

Will be closed by #77