Introducing Holden - A Certificate Generator App using Flutter

Tirth Patel
Aubergine Solutions
5 min readDec 18, 2019

If you’re an event organizer, you know the pain of generating the certificates for participants. What if there was a mobile application that can do this tedious task for you?!

🥁🥁

Introducing Holden, easy to use certificate generator app made using Flutter.

Demo

📝 Overview

  • The user selects an xlsx file from the device.
  • The app parses xlsx file and displays the names (of participants) in a list.
  • Clicking on an individual name opens the certificate of that participant.
  • The user can select the table from the drop-down.
  • A Certificate can be downloaded, viewed and shared.
  • Multiple Certificates can be shared with others via other applications (Google Drive, WhatsApp, Gmail, etc.) or saved locally on the device.

🔌 Prerequisites

$ flutter create certificate_generator

📁 Directory Structure

Directory Structure

🍺 Dependencies

  • Add the following dependencies in pubspec.yaml file and run the following command to retrieve them.
pubspec.yaml
$ flutter packages get

🎹 Coding

  • There is a total of 3 screens in the app: HomeScreen, ResultScreen & ViewerScreen.

🚪 main.dart

  • Here we have set up routes, providers, runtime permission requests, and theme for the application.
main.dart

🏡 HomeScreen

  • Initially, suggestion text is shown to the user when no file is selected.
lib/screens/home.dart
  • Format of the xlsx should be like this:
Sample xlsx file
  • HomeScreen has a floating action button, clicking on which file picker is shown where the user can select an xlsx file that has names of participants.
FAB in lib/screens/home.dart
  • HomeProvider exposes setter & getters to manipulate the path of user-selected xlsx file, names of tables from user-selected xlsx file, and the name of the currently selected table from user-selected xlsx file.
lib/providers/home.dart
  • Once the file is selected, HomeProvider sets the path of that file using the setter & notifies the listeners. So, the body of HomeScreen now displays the list of names parsed using spreadsheet decoder from the selected xlsx file. We need to pass the result of File(filePath).readAsBytesSync() the inside decodeBytes()method.
  • Clicking on a name shows the certificate of that participant in ResultScreen.
List of names in lib/screens/home.dart
  • Now, in the app-bar a drop-down gets visible. It displays names all tables from xlsx file and choosing an option displays names from that table.
Table Dropdown in lib/screens/home.dart
  • A second FAB with share icon gets visible, clicking on which shows the share dialog to share PDFs of all the participants from the selected table.
Share FAB in lib/screens/home.dart
HomeScreen Flow

📰 ResultScreen

  • It displays the certificate of the individual participant.
lib/screens/result.dart
  • The certificate has 3 actions: 🔽 Download, 👀 View, and 📨 Share.
Download, View, and Share Buttons
  • When the user clicks on the download button PDF is generated with the help of pdf package. Snackbar is shown when the certificate is generated which also contains an action to quickly view to the certificate.
Download button in lib/screens/result.dart
  • The code for PDF generation is extracted into a separate method. Once the pdf is generated it is saved on the user’s device inside the application documents directory. PDF package provides widgets to build UI for PDF and its widget system is very similar to Flutter’s widget system. So, it’s easy to replicate certificate UI for PDF.
pdfGenerator method in lib/utils/commons.dart
  • When the user clicks on the view button, the downloaded certificate is opened in ViewerScreen. If the certificate doesn’t exist then the “Not Found” message is shown in SnackBar with download action to quickly download the certificate.
View Button in lib/screens/result.dart

When the user clicks on the share button then share dialog is shown with the help of share_extend plugin to the user so the certificate can be shared with others via other apps. If the certificate doesn’t exist then the “Not Found” message is shown in SnackBar with download action to quickly download the certificate.

Share Button in lib/screens/result.dart
ResultScreen Flow

👀 ViewerScreen

lib/screens/view.dart
ViewerScreen Flow

This is a WIP project. We’re planning to add support for more file formats, the ability to use a URL of spreadsheets for simplicity, and certificate designer for customization.

You can check out the source code of the app here. Feel free to contribute to the project by creating issues or sending pull-requests.

That’s it for this one. Thank you for reading this 💙

--

--