BCBP

BCBP Version License: MIT

Encoding/decoding library for the IATA Bar Coded Boarding Pass

  • Supports version 6 of the BCBP standard
  • Supports any number of legs

Requirements

  • Dart 2.16.0 or newer

Usage

Add BCBP to your pubspec.yaml file:

dependencies:
  bcbp: lastest

Import get in files that it will be used:

import 'package:bcbp/bcbp.dart';

Encode

String bcbpEncode(BarCodedBoardingPass bcbp)

Example

import 'package:bcbp/bcbp.dart';

void main() {
  final output = bcbpEncode(
    BarCodedBoardingPass(
      data: BoardingPassData(
        legs: [
          Leg(
            operatingCarrierPNR: "LH8W9P",
            departureAirport: "HAN",
            arrivalAirport: "SGN",
            operatingCarrierDesignator: "VN",
            flightNumber: "1187",
            flightDate: DateTime.parse("2025-04-30T00:00:00.000Z"),
            compartmentCode: "Y",
            seatNumber: "001A",
            checkInSequenceNumber: "0025",
            passengerStatus: "1",
          )
        ],
        passengerName: "LE/PHUCANH",
      ),
    ),
  );
  print(output);
  // M1LE/PHUCANH           LH8W9P HANSGNVN 1187 120Y001A0025 106>10000
}

Decode

BarCodedBoardingPass bcbpDecode(String barcodeString, {int? referenceYear})

Example

import 'package:bcbp/bcbp.dart';

void main() {
  final output = bcbpDecode("M1LE/PHUCANH           LH8W9P HANSGNVN 1187 120Y001A0025 106>10000");
  print(output.data?.passengerName);
  // LE/PHUCANH
}

Decode with Reference Year

Define the year which is used when parsing date fields. If this is undefined, the current year is used.

import 'package:bcbp/bcbp.dart';

void main() {
  final output = bcbpDecode(
      "M1LE/PHUCANH           LH8W9P HANSGNVN 1187 120Y001A0025 106>10000",
      referenceYear: 2024
  );
  print(output.data?.legs?[0].flightDate?.toIso8601String());
  // 2024-04-29T00:00:00.000Z
}

BarCodedBoardingPass

See types.dart for the definition.

Example app

Find the example app here.

Contributing

Contributions are welcome. In case of any problems look at existing issues, if you cannot find anything related to your problem then open an issue. Create an issue before opening a pull request for non trivial fixes. In case of trivial fixes open a pull request directly.

Libraries

bcbp
A library for encoding and decoding IATA Bar Coded Boarding Passes (BCBP).