flutter_esc_printer 0.1.0

  • Readme
  • Changelog
  • Example
  • Installing
  • 73

flutter_esc_printer #

Flutter ESC Printer originally inpire from esc_pos_utils flutter_bluetooth_serial. It can be used to print vai bluetooth mac address or network ip address.

Getting Started #

    _testPrint() async {
    const PaperSize paper = PaperSize.mm80;
    String address = "DC:0D:30:8A:B7:56"; // 192.168.10.10
    if(address.isIpAddress){
      //print vai ip address
      
        PrinterNetworkManager _printerNetworkManager = PrinterNetworkManager();
      _printerNetworkManager.selectPrinter(address);
      final res = await _printerNetworkManager.printTicket(await testTicket(paper));

      print(res.msg);
      
    }else if(address.isMacAddress) {
      //print vai mac address
      PrinterBluetoothManager _printerBluetoothManager = PrinterBluetoothManager();
      _printerBluetoothManager.selectPrinter(address);
      final res = await _printerBluetoothManager.printTicket(await testTicket(paper));
      
      print(res.msg);
    
    }else{
      //print("Error :e");
    }
  }

0.1.0 #

  • TODO: add license and add seperate into bluetooth printer to avoid chunks

0.0.1 #

  • TODO: Describe initial release.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_esc_printer/flutter_esc_printer.dart';

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

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  PrinterBluetoothManager _printerBluetoothManager = PrinterBluetoothManager();
  PrinterNetworkManager _printerNetworkManager = PrinterNetworkManager();
  @override
  void initState() {
    super.initState();
  }
  
  Future<Ticket> testTicket(PaperSize paper) async {
    final Ticket ticket = Ticket(paper);

    ticket.text(
        'Regular: aA bB cC dD eE fF gG hH iI jJ kK lL mM nN oO pP qQ rR sS tT uU vV wW xX yY zZ');
    ticket.text('Special 1: àÀ èÈ éÉ ûÛ üÜ çÇ ôÔ',
        styles: PosStyles(codeTable: PosCodeTable.westEur));
    ticket.text('Special 2: blåbærgrød',
        styles: PosStyles(codeTable: PosCodeTable.westEur));

    ticket.text('Bold text', styles: PosStyles(bold: true));
    ticket.text('Reverse text', styles: PosStyles(reverse: true));
    ticket.text('Underlined text',
        styles: PosStyles(underline: true), linesAfter: 1);
    ticket.text('Align left', styles: PosStyles(align: PosAlign.left));
    ticket.text('Align center', styles: PosStyles(align: PosAlign.center));
    ticket.text('Align right',
        styles: PosStyles(align: PosAlign.right), linesAfter: 1);

    ticket.feed(2);

    ticket.cut();
    return ticket;
  }

  _testPrint() async {
    const PaperSize paper = PaperSize.mm80;
    String address = "DC:0D:30:8A:B7:56"; // 192.168.10.10
    if(address.isIpAddress){
      //print vai ip address
      _printerNetworkManager.selectPrinter(address);
      final res = await _printerNetworkManager.printTicket(await testTicket(paper));
      
    }else if(address.isMacAddress) {
      //print vai mac address
      _printerBluetoothManager.selectPrinter(address);
      final res = await _printerBluetoothManager.printTicket(await testTicket(paper));
    
    }else{
      //print("Error :e");
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: RaisedButton(onPressed: () {
            _testPrint();
          }, child: Text("PRINT")),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_esc_printer: ^0.1.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support 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:flutter_esc_printer/flutter_esc_printer.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
50
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
90
Overall:
Weighted score of the above. [more]
73
Learn more about scoring.

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

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform linux

Because:

  • package:flutter_esc_printer/flutter_esc_printer.dart that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because:

  • package:flutter_esc_printer/flutter_esc_printer.dart that declares support for platforms: android, ios

Package does not support Flutter platform web

Because:

  • package:flutter_esc_printer/flutter_esc_printer.dart that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because:

  • package:flutter_esc_printer/flutter_esc_printer.dart that declares support for platforms: android, ios

Package not compatible with SDK dart

Because:

  • flutter_esc_printer that is a package requiring null.

Maintenance issues and suggestions

Support latest dependencies. (-10 points)

The version constraint in pubspec.yaml does not support the latest published versions for 1 dependency (esc_pos_utils).

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.6.0 <3.0.0
esc_pos_utils ^0.3.6 0.3.6 0.4.5
flutter 0.0.0
flutter_bluetooth_serial ^0.2.2 0.2.2
Transitive dependencies
archive 2.0.13
args 1.6.0
charcode 1.1.3
collection 1.14.12 1.14.13
convert 2.1.1
crypto 2.1.5
csslib 0.16.1
gbk_codec 0.3.2
hex 0.1.2
html 0.14.0+3
image 2.1.14
meta 1.1.8 1.2.1
path 1.7.0
petitparser 3.0.4
sky_engine 0.0.99
source_span 1.7.0
term_glyph 1.1.0
typed_data 1.1.6 1.2.0
vector_math 2.0.8
xml 4.2.0
Dev dependencies
flutter_test