FlutterFlow Tutorial

Generate Invoices in FlutterFlow

Add PDF invoice generation to your FlutterFlow app. Let your users create and send invoices directly from their phone.

Vincent Ventalon
Vincent Ventalon
·Updated

Overview

Building a mobile invoicing app? Your users expect to create professional invoices and send them instantly. This tutorial shows you how to add PDF invoice generation to your FlutterFlow app using TemplateFox.

We'll use a professional invoice template and connect it to your app via FlutterFlow's API Call feature. The same approach works for receipts, quotes, or any other document.

What you'll build: A "Generate Invoice" button that creates a PDF invoice with customer details, line items, and totals — then lets users download or share it.

1

Choose an invoice template

Start by picking an invoice template. We'll use the Modern Invoice with QR Code template — it's designed for mobile payments and includes a QR code for instant payment.

  1. Go to Invoice Templates
  2. Choose a template that fits your use case
  3. Click Use Template to add it to your dashboard

Other options: Freelancer Invoice for consultants, EU Corporate Invoice for European businesses, US Invoice with ACH for bank transfers.

You can also create your own template with our drag-and-drop editor. Add your logo, adjust colors, and include any fields you need.

2

Get your API key and template ID

You'll need two things from your TemplateFox dashboard:

API Key

Found in Dashboard → API

Starts with sk_

Template ID

Found in Dashboard → Templates

UUID like a1b2c3d4-...

Security tip: Don't hardcode your API key in the app for production. Store it in FlutterFlow's environment variables, or fetch it from your backend (Firebase Functions, Supabase Edge Functions).

3

Create the API Call in FlutterFlow

Now set up the API call that will generate your invoices.

3.1 — Create a new API Call

  1. In FlutterFlow, go to API Calls in the left sidebar
  2. Click + Add API Call
  3. Name it generateInvoice

3.2 — Configure the request

Method:POST
URL:https://api.pdftemplateapi.com/v1/pdf
Headers:
Content-Type: application/json
X-API-Key: your-api-key

3.3 — Set up the request body

The body contains your template ID and invoice data. Here's the structure:

{
"template_id": "your-invoice-template-uuid",
"data": {
// Your business info (hardcode these)
"company_name": "Your Business Name",
"company_address": "123 Main St, City",
"company_email": "billing@yourbusiness.com",
// Customer info (from your app)
"client_name": "John Doe",
"client_email": "john@example.com",
"client_address": "456 Oak Ave, Town",
// Invoice details
"invoice_number": "INV-2026-001",
"invoice_date": "March 20, 2026",
"due_date": "April 20, 2026",
// Line items (array)
"items": [
{
"description": "Web Development",
"quantity": 10,
"unit_price": 150,
"amount": 1500
},
{
"description": "UI Design",
"quantity": 5,
"unit_price": 200,
"amount": 1000
}
],
// Totals
"subtotal": 2500,
"tax": 500,
"total": 3000
}
}

3.4 — Map FlutterFlow variables

In the Body tab, click the +Variable icon next to dynamic fields. Map them to your app data:

Hardcode (static)

  • template_id
  • company_name
  • company_address
  • company_email

Map from app (dynamic)

  • client_name → customer doc
  • items → line items list
  • total → calculated amount
  • invoice_number → generated ID

Tip: Use FlutterFlow's Custom Functions to format dates, calculate totals, or generate invoice numbers before passing them to the API.

4

Trigger and handle the response

Add a "Generate Invoice" button

  1. Add a Button widget to your invoice page
  2. Set the text to "Generate Invoice" or "Download PDF"
  3. Add an ActionAPI Call
  4. Select your generateInvoice API call

Handle the response

The API returns the PDF URL:

{
"url": "https://storage.pdftemplateapi.com/invoices/abc123.pdf",
"credits_used": 1,
"credits_remaining": 99
}

Add follow-up actions to let users view or share the invoice:

1

Download / Open in browser

Add Launch URL action with the response url. Opens the PDF for download or viewing.

2

Share via native share sheet

Add Share action. Users can send the invoice via WhatsApp, email, or any other app.

3

Save to Firestore

Add Backend Call to save the PDF URL to your invoices collection. Useful for invoice history.

That's it! Your FlutterFlow app can now generate professional PDF invoices. Users tap a button, the invoice generates in 1-2 seconds, and they can download or share it instantly.

Next steps

Frequently asked questions

Can I test the API call before using it in my app?

Yes! Use FlutterFlow's built-in API testing feature. After configuring your API call, click 'Test API Call' to see the response. You can also test directly in your TemplateFox dashboard's Preview tab with sample JSON data.

How do I pass customer data from Firestore to the invoice?

In FlutterFlow, when configuring the API call body, click the variable icon next to each field. You can select Firestore document fields directly. For example, map customerDoc.name to client_name and customerDoc.address to client_address.

Can I include multiple line items on the invoice?

Yes! The items field accepts an array. In FlutterFlow, you can pass a list of items from your app state or Firestore. The template automatically generates a row for each item and calculates totals.

What should I do with the PDF URL after generation?

The API returns a PDF URL that you can use in several ways: display it in a WebView widget, trigger a download using the 'Launch URL' action, share it via the native share sheet, or save the URL to Firestore for invoice history.

Does this work offline?

PDF generation requires an internet connection since it calls the TemplateFox API. For offline scenarios, consider generating invoices when the user is online and caching the PDF URLs in local storage or Firestore.

Automate your PDF generation

Complete documentation, no-code integrations, and a powerful API to help you generate PDFs at scale. Let us handle the boring stuff.