Marl Designs
ย ยทย newbie self-taught dev.

I tried to use PDF package from pub.dev

Any idea what is wrong?
I tried to use this package

but in my custom widget its already validated but nothing show up on the preview of the widget

here's the code:

// Automatic FlutterFlow imports
import '/flutter_flow/flutter_flow_theme.dart';
import '/flutter_flow/flutter_flow_util.dart';
import '/custom_code/widgets/index.dart'; // Imports other custom widgets
import '/flutter_flow/custom_functions.dart'; // Imports custom functions
import 'package:flutter/material.dart';
// Begin custom widget code
// DO NOT REMOVE OR MODIFY THE CODE ABOVE!

import 'package:pdf/pdf.dart';
import 'package:archive/archive.dart';
import 'package:barcode/barcode.dart';
import 'package:bidi/bidi.dart';
import 'package:crypto/crypto.dart';
import 'package:path_parsing/path_parsing.dart';
import 'package:vector_math/vector_math.dart';
import 'package:meta/meta.dart';
import 'package:image/image.dart';
import 'dart:io';
import 'package:pdf/widgets.dart' as pw;

class CustomPDFreader extends StatefulWidget {
  const CustomPDFreader({
    Key? key,
    this.width,
    this.height,
  }) : super(key: key);

  final double? width;
  final double? height;

  @override
  _CustomPDFreaderState createState() => _CustomPDFreaderState();
}

class _CustomPDFreaderState extends State<CustomPDFreader> {
  Future<void> main() async {
    final pdf = pw.Document();

    pdf.addPage(
      pw.Page(
        build: (pw.Context context) => pw.Center(
          child: pw.Text('Hello World!'),
        ),
      ),
    );

    final file = File('example.pdf');
    await file.writeAsBytes(await pdf.save());
  }

  @override
  Widget build(BuildContext context) {
    return Container();
  }
}

Did I make it right or not?
Please help me, Thank you for advance.
I really appreciate your help and I'm so grateful with this community.

1 reply