marvel_printer 0.0.3 copy "marvel_printer: ^0.0.3" to clipboard
marvel_printer: ^0.0.3 copied to clipboard

PlatformAndroid

A Flutter plugin for connecting and printing receipts to POS thermal printers over USB (and future support for Bluetooth/Network). Provides APIs for printing text, images, and Arabic content using the POSSDK.

example/lib/main.dart

import 'dart:typed_data';
import 'package:flutter/material.dart';
import 'package:marvel_printer/marvel_printer.dart';

void main() => runApp(const MyApp());

class MyApp extends StatelessWidget {
  const MyApp({super.key});
  @override
  Widget build(BuildContext context) => MaterialApp(home: const Home());
}

class Home extends StatefulWidget {
  const Home({super.key});
  @override
  State<Home> createState() => _HomeState();
}

class _HomeState extends State<Home> {
  Future<void> _printImage(Uint8List png, {int widthDots = 512}) async {
    final ok = await MarvelPrinter.printReceiptImage(
      pngBytes: png,
      widthDots: widthDots,
    );
    debugPrint('printReceiptImage: $ok');
  }

  Future<void> _printSaleDemo() async {
    final saleJson = {
      'seller_name': 'CodeIT Store',
      'seller_vat_no': '123456789',
      'has_vat': true,
      'reference_no': 'INV-1001',
      'warehouseName': 'Main Branch',
      'payment_method': 'Cash',
      'products': [
        {
          'product_name': 'قهوة عربية',
          'unitName': 'cup',
          'price': 5.0,
          'quantity': 2,
          'total': 10.0,
        },
      ],
      'totalWithoutDiscountAndVat': 10.0,
      'totalDiscount': 0.0,
      'vatAmount': 1.5,
      'grandTotal': 11.5,
    };
    final ok = await MarvelPrinter.printSample();
    debugPrint('printSale: $ok');
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('Marvel Printer Example')),
      body: Center(
        child: Column(
          mainAxisSize: MainAxisSize.min,
          children: [
            ElevatedButton(
              onPressed: () async {
                await MarvelPrinter.autoConnect();
              },
              child: const Text('Auto connect'),
            ),
            ElevatedButton(
              onPressed: _printSaleDemo,
              child: const Text('Print sale (Android)'),
            ),
          ],
        ),
      ),
    );
  }
}
0
likes
140
points
6
downloads

Publisher

unverified uploader

Weekly Downloads

A Flutter plugin for connecting and printing receipts to POS thermal printers over USB (and future support for Bluetooth/Network). Provides APIs for printing text, images, and Arabic content using the POSSDK.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on marvel_printer

Packages that implement marvel_printer