Code Monkey home page Code Monkey logo

flutter_sunmi_printer's Introduction

flutter_sunmi_printer

Plugin allows to print thermal receipts using Sunmi device with a built-in printer. Tested on Sunmi V2.

Features

  • text: print text with styles (bold, underline, align, font size)
  • row: print a row containing up to 12 columns (total columns width must be equal to 12)
  • image: print an image with alignment
  • hr: print full width separator
  • emptyLines: feed n lines
  • boldOn, boldOff
  • underlineOn, underlineOff

TODO

  • Print QR codes
  • Print Barcodes

Getting Started

import 'package:flutter_sunmi_printer/flutter_sunmi_printer.dart';

// Test regular text
SunmiPrinter.hr(); // prints a full width separator
SunmiPrinter.text(
    'Test Sunmi Printer',
    styles: SunmiStyles(align: SunmiAlign.center),
);
SunmiPrinter.hr();

// Test align
SunmiPrinter.text(
    'left',
    styles: SunmiStyles(bold: true, underline: true),
);
SunmiPrinter.text(
    'center',
    styles:
        SunmiStyles(bold: true, underline: true, align: SunmiAlign.center),
);
SunmiPrinter.text(
    'right',
    styles: SunmiStyles(bold: true, underline: true, align: SunmiAlign.right),
);

// Test text size
SunmiPrinter.text('Extra small text',
    styles: SunmiStyles(size: SunmiSize.xs));
SunmiPrinter.text('Medium text', styles: SunmiStyles(size: SunmiSize.md));
SunmiPrinter.text('Large text', styles: SunmiStyles(size: SunmiSize.lg));
SunmiPrinter.text('Extra large text',
    styles: SunmiStyles(size: SunmiSize.xl));

// Test row
SunmiPrinter.row(
    cols: [
        SunmiCol(text: 'col1', width: 4),
        SunmiCol(text: 'col2', width: 4, align: SunmiAlign.center),
        SunmiCol(text: 'col3', width: 4, align: SunmiAlign.right),
    ],
);

// Test image
ByteData bytes = await rootBundle.load('assets/rabbit_black.jpg');
final buffer = bytes.buffer;
final imgData = base64.encode(Uint8List.view(buffer));
SunmiPrinter.image(imgData);

SunmiPrinter.emptyLines(3);

flutter_sunmi_printer's People

Contributors

arjunnagraj avatar trapeye avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.