Last updated:
0 purchases
gpos720 printer
gpos720_printer #
A Flutter plugin to integrate printing in the
Gertec GPOS720.
Features #
Methods
Implemented
checarImpressora
✔️
avancaLinha
✔️
imprimirTexto
✔️
imprimirImagem
✔️
imprimirImagemFiltrada
✔️
imprimirCodigoDeBarra
✔️
imprimirCodigoDeBarraImg
✔️
imprimirTodasFuncoes
✔️
imprimirEscPos
❌️
Requirements #
Android minimum sdk version >= 22.
Flutter version >= 2.0.0.
Dart version >= 2.12.0.
Installation #
Step 1 #
In the "/android/src/main/AndroidManifest.xml", add:
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
...
<uses-feature android:name="android.hardware.usb.host" />
...
</manifest>
copied to clipboard
Step 2 #
The Android Gradle Plugin (AGP) doesn’t support direct local AAR dependencies in Android library
projects due to how it packages the resulting AAR, so we need to do the following configurations.
In the "/android/app/libs/" directory, paste the two .aar dependencies used by this library. You
can find them in
this link.
Then in the "android/app/build.gradle", add:
...
Android{
...
dependencies {
implementation fileTree(dir: 'libs', include: ['*.aar'])
}
}
...
copied to clipboard
Lastly in the "android/build.gradle", add:
...
allprojects {
repositories {
google()
mavenCentral()
flatDir {
dirs 'libs'
}
}
}
...
copied to clipboard
Getting Started #
Just instantiate the "Gpos720Printer" and invoke the desired functions as shown
in this
example project.
You must have a Gertec GPOS720 device to be able to use this plugin.
Instantiate: #
Instantiate the "Gpos720Printer" object like this:
import 'package:gpos720_printer/gpos720_printer.dart';
void main() {
Gpos720Printer gpos720Printer = Gpos720Printer(finalizarImpressao: false);
}
copied to clipboard
You can pass the optional boolean parameter finalizarImpressao in the constructor to call
the fimImpressao function after executing a print command. By default, this parameter is set
to false, so it might be necessary to call fimImpressao after executing all the desired print
commands.
Documentation #
Methods: #
Future<PrinterStatus> checarImpressora()
Description: Checks the printer’s status.
Returns:
A
PrinterStatus enum indicating the printer’s status.
Throws: A PlatformException or a MissingPluginException.
Future<PrinterStatus> fimImpressao()
Description: Prints all buffered printer commands.
Returns:
A
PrinterStatus enum indicating the printer’s status.
Throws: A PlatformException or a MissingPluginException.
Future<PrinterStatus> avancaLinha(int quantLinhas)
Description: Adds line breaks to the current printout.
Returns:
A
PrinterStatus enum indicating the printer’s status.
Parameters:
quantLinhas: An Integer specifying the desired number of line breaks.
Throws: A PlatformException or a MissingPluginException.
Future<PrinterStatus> imprimirTexto(String mensagem, {TextOptions? options, int size = defaultFontSize, Font? font, AlignmentTypes align = AlignmentTypes.left})
Description: Prints text.
Returns:
A
PrinterStatus enum indicating the printer’s status.
Parameters:
mensagem: A String with the desired text to be printed.
options (optional): A TextOptions specifying if the text will be render as bold, italic or
underlined.
size (optional): An Integer specifying the desired font size.
Font (optional): A Font specifying the desired font to be used in the text.
align (optional): An AlignmentTypes enum specifying the desired alignment. By default,
align will be left.
Throws: A PlatformException or a MissingPluginException.
Future<PrinterStatus> imprimirImagem(Uint8List data, int width, int height, {AlignmentTypes align = AlignmentTypes.center})
Description: Prints raw black and white images only. You can use the
method
binaryFilterWithDithering to apply a binary filter with dithering to the image.
Returns:
A
PrinterStatus enum indicating the printer’s status.
Parameters:
data: A Uint8List with the raw data of the black and white image.
width: An Integer specifying the desired width.
height: An Integer specifying the desired height.
align (optional): An AlignmentTypes enum specifying the desired alignment. By default,
align will be center.
Throws: A PlatformException or a MissingPluginException.
Future<PrinterStatus> imprimirImagemFiltrada(Uint8List data, int width, int height, {AlignmentTypes align = AlignmentTypes.center, double? blackTolerance, double? ditheringTolerance})
Description: Apply a binary filter with dithering and print the raw image.
Returns:
A
PrinterStatus enum indicating the printer’s status.
Parameters:
data: A Uint8List with the raw data of the image.
width: An Integer specifying the desired width.
height: An Integer specifying the desired height.
align (optional): An AlignmentTypes enum specifying the desired alignment. By default,
align will be center.
blackTolerance (optional): A double representing the tolerance level for using black
color. The
default value is 0.34.
ditheringTolerance (optional): A double representing the tolerance for using dithering to
represent
colors. The default value is 0.67.
Throws: A PlatformException or a MissingPluginException.
Future<PrinterStatus> imprimirCodigoDeBarra(String mensagem, int width, int height, BarcodeTypes barcodeType)
Description: Prints various types of barcodes.
Returns:
A
PrinterStatus enum indicating the printer’s status.
Parameters:
mensagem: A String specifying the desired data on the barcode.
width: An Integer specifying the desired width.
height: An Integer specifying the desired height.
barcodeTypes: A BarcodeTypes enum specifying the desired barcode type.
Throws: A PlatformException or a MissingPluginException.
Future<PrinterStatus> imprimirCodigoDeBarraImg(String mensagem, int width, int height, BarcodeTypes barcodeType)
Description: Prints various types of barcodes, rendering them as images.
Returns:
A
PrinterStatus enum indicating the printer’s status.
Parameters:
mensagem: A String specifying the desired data on the barcode.
width: An Integer specifying the desired width.
height: An Integer specifying the desired height.
barcodeTypes: A BarcodeTypes enum specifying the desired barcode type.
Throws: A PlatformException or a MissingPluginException.
Future<PrinterStatus> imprimirTodasFuncoes(Uint8List data, int width, int height)
Description: Prints all printer functions.
Returns:
A
PrinterStatus enum indicating the printer’s status.
Parameters:
data: A Uint8List with the raw data of the black and white image.
width: An Integer specifying the desired width.
height: An Integer specifying the desired height.
Throws: A PlatformException or a MissingPluginException.
Configuration parameters: #
BarcodeTypes
An enum to indicate the type of barcode to be
printed.
Click here to consult the available types.
AlignmentTypes
An enum to indicate the desired alignment for the command to be
printed.
Click here to consult the available types.
Font
An object to specify the desired font for printing. The constructor receives the font name as a
parameter, and the font must be available in the assets folder under the directory "/fonts". By
default, it is set to "
NORMAL",
click here to view the implementation.
TextOptions
An object that specifies the desired text decoration. It can add bold, italic, or underline styles.
By default, all styles are set to
false,
click here to view the implementation.
Output: #
PrinterStatus
An enum to indicate the current status of the
printer, it can be parsed to a String using
the ".getLabel"
method.
Click here to view the implementation.
ImageUtils: #
binaryFilterWithDithering
A method that applies a binary filter with dithering to an image, converting it to black and white
while using dithering to represent colors that are not too dark. The method takes the following
parameters:
image: A Uint8List representing the image.
blackTolerance: A double representing the tolerance level for using black color. The default
value is 0.34.
ditheringTolerance: A double representing the tolerance for using dithering to represent
colors. The default value is 0.67.
Returns: A Uint8List with the filtered image.
Click
here to view the implementation.
TODO #
Implement plugin tests.
Print raw ESC/POS commands.
For personal and professional use. You cannot resell or redistribute these repositories in their original state.
There are no reviews.