custom_save_pdf 0.0.1 copy "custom_save_pdf: ^0.0.1" to clipboard
custom_save_pdf: ^0.0.1 copied to clipboard

outdated

Flutter Package allowed you to saving pdf files in custom folder in phone storage

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:invoice_maker/sv.dart';

import 'invoice_service.dart';
import 'model/product.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatelessWidget {
  const MyApp({Key? key}) : super(key: key);

  // This widget is the root of your application.
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'Flutter Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: HomePage(),
    );
  }
}

class HomePage extends StatefulWidget {
  HomePage({Key? key}) : super(key: key);

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  TextEditingController text = TextEditingController();

  final PdfInvoiceService service = PdfInvoiceService();
  List<Product> products = [
    Product("Membership", 9.99, 19),
    Product("Nails", 0.30, 19),
    Product("Hammer", 26.43, 19),
    Product("Hamburger", 5.99, 7),
  ];
  int number = 0;
  @override
  void initState() {
    // TODO: implement initState
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Padding(
        padding: const EdgeInsets.all(8.0),
        child: Column(
          crossAxisAlignment: CrossAxisAlignment.center,
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            SizedBox(
              width: double.infinity,
              child: TextField(
                controller: text,
              ),
            ),
            SizedBox(
              height: 50,
            ),
            ElevatedButton(
              onPressed: () async {
                final data = await service.createHelloWorld(text.text);

                CustomPdfFolder.save(
                    byteList: data,
                    nameOfFolder: 'nasr',
                    openPDF: true,
                    onSaved: (v) {},
                    onError: (error, code) {
                      print(error);
                      print(code);
                    });
                number++;
              },
              child: const Text("Create PDF"),
            ),
          ],
        ),
      ),
    );
  }

  getTotal() => products
      .fold(0.0,
          (double prev, element) => prev + (element.price * element.amount))
      .toStringAsFixed(2);

  getVat() => products
      .fold(
          0.0,
          (double prev, element) =>
              prev +
              (element.price / 100 * element.vatInPercent * element.amount))
      .toStringAsFixed(2);
}

//
// Expanded(
// child: ListView.builder(
// itemBuilder: (context, index) {
// final currentProduct = products[index];
// return Row(
// children: [
// Expanded(child: Text(currentProduct.name)),
// Expanded(
// child: Column(
// children: [
// Text(
// "Price: ${currentProduct.price.toStringAsFixed(2)} €"),
// Text(
// "VAT ${currentProduct.vatInPercent.toStringAsFixed(0)} %")
// ],
// crossAxisAlignment: CrossAxisAlignment.center,
// ),
// ),
// Expanded(
// child: Row(
// children: [
// Expanded(
// child: IconButton(
// onPressed: () {
// setState(() => currentProduct.amount++);
// },
// icon: const Icon(Icons.add),
// ),
// ),
// Expanded(
// child: Text(
// currentProduct.amount.toString(),
// textAlign: TextAlign.center,
// ),
// ),
// Expanded(
// child: IconButton(
// onPressed: () {
// setState(() => currentProduct.amount--);
// },
// icon: const Icon(Icons.remove),
// ),
// )
// ],
// ),
// )
// ],
// );
// },
// itemCount: products.length,
// ),
// ),
// Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [const Text("VAT"), Text("${getVat()} €")],
// ),
// Row(
// mainAxisAlignment: MainAxisAlignment.spaceBetween,
// children: [const Text("Total"), Text("${getTotal()} €")],
// ),
3
likes
0
points
54
downloads

Publisher

verified publisherabom.me

Weekly Downloads

Flutter Package allowed you to saving pdf files in custom folder in phone storage

Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

cupertino_icons, flutter, open_document, path_provider, permission_handler

More

Packages that depend on custom_save_pdf