hexal_pdf_generator 2.0.1

  • Readme
  • Changelog
  • Installing
  • 55

Hexal PDF Generator #

Generates PDFs of pages of Hexal cards for print.

Created from templates made available by Stagehand under a BSD-style license.

Usage #

A simple usage example:

import 'package:hexal_generator/generator.dart';
import 'package:image/image.dart';
import 'dart:typed_data';

main() async {
  // Load fonts used in cards. Optionally add bold and semibold variants.
  final ByteData fontData = await readBytes("assets/courier_regular.ttf");

  // Load icons used for element symbols.
  final Map<String, Image> elements = {
    'fire': await readBytes("assets/icon_fire.png").then((data) => decodeImage(data)),
    // Images for other elements

  // Load images used as backing frames for cards based on element.
  final Map<String, Image> frames = {
    'fire': await readBytes("assets/frame_fire.png").then((data) => decodeImage(data)),
    // Images for other frames

  // Create generator instance and add cards.
  final Generator generator = Generator(assets);

  Image cardImage = await readBytes("assets/frame_fire.png").then((data) => decodeImage(data))

    name: "Test Card",
    id: "[0.000]",
    type: "Token Creature",
    stats: "0 / 0",
    text: "<Keyword>s and [Fire]s",
    element: 'neutral',
    cost: {
      'neutral': 1,
    image: cardImage,

  List<int> output = generator.saveDocument();

  // Convert output from generator into PDF blob.
  final Int8List int8array = Int8List.fromList(intList);
  final Blob blob = Blob([int8array], 'application/pdf');

  // Create URL referencing blob that could be displayed to a user.
  String url = Url.createObjectUrlFromBlob(blob);

1.0.0 #

  • Initial version

2.0.0 #

  • Removes generator card and asset access from user to simplify usage.

2.0.1 #

  • Fixes a bug where building would crash if given a card with null cost.

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:

  hexal_pdf_generator: ^2.0.1

2. Install it

You can install packages from the command line:

with pub:

$ pub get

with Flutter:

$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:

import 'package:hexal_pdf_generator/hexal_pdf_generator.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

We analyzed this package on Mar 30, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.7.1
  • pana: 0.13.6

Maintenance suggestions

Maintain an example. (-10 points)

Create a short demo in the example/ directory to show how to use this package.

Common filename patterns include main.dart, example.dart, and hexal_pdf_generator.dart. Packages with multiple examples should provide example/README.md.

For more information see the pub package layout conventions.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.4.0 <3.0.0
image ^2.1.4 2.1.12
meta ^1.1.8 1.1.8
pdf ^1.3.18 1.6.0
Transitive dependencies
archive 2.0.13
args 1.6.0
barcode 1.5.0
charcode 1.1.3
collection 1.14.12
convert 2.1.1
crypto 2.1.4
path 1.6.4
petitparser 3.0.2
qr 1.2.0
typed_data 1.1.6
utf 0.9.0+5
vector_math 2.0.8
xml 3.7.0 4.1.0
Dev dependencies
pedantic ^1.9.0
test ^1.6.0