gpos720_printer 0.0.7+1
gpos720_printer: ^0.0.7+1 copied to clipboard
A Flutter plugin to integrate printing in the Gertec GPOS720.
gpos720_printer #
A Flutter plugin to integrate printing in the Gertec GPOS720.
Features #
| Methods | Implemented |
|---|---|
| checarImpressora | ✔️ |
| fimImpressao | ✔️ |
| avancaLinha | ✔️ |
| imprimirTexto | ✔️ |
| imprimirImagem | ✔️ |
| imprimirCodigoDeBarra | ✔️ |
| 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>
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'])
}
}
...
- Lastly in the "android/build.gradle", add:
...
allprojects {
repositories {
google()
mavenCentral()
flatDir {
dirs 'libs'
}
}
}
...
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();
}
Documentation #
Methods: #
Future<PrinterStatus> avancaLinha(int quantLinhas)
Remember to call the method ‘fimImpressao()’ to print what is in the print buffer.
- 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> 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: Finalizes the printing queue.
- Returns: A PrinterStatus enum indicating the printer’s status.
- Throws: A PlatformException or a MissingPluginException.
Future<PrinterStatus> imprimirCodigoDeBarra(String mensagem, int width, int height, BarcodeTypes barcodeType)
Remember to call the method ‘fimImpressao()’ to print what is in the print buffer.
- 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> imprimirImagem(Uint8List data, int width, int height, {AlignmentTypes align = AlignmentTypes.center})
Remember to call the method ‘fimImpressao()’ to print what is in the print buffer.
- Description: Prints raw images. Only accepts JPG images.
- Returns: A PrinterStatus enum indicating the printer’s status.
- Parameters:
- data: A Uint8List with the JPG image raw data.
- 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> imprimirTexto(String mensagem, {TextOptions? options, int size = defaultFontSize, Font? font, AlignmentTypes align = AlignmentTypes.left})
Remember to call the method ‘fimImpressao()’ to print what is in the print buffer.
- 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> imprimirTodasFuncoes(Uint8List data, int width, int height)
This method already executes the ‘fimImpressao()’ method.
- Description: Prints all printer functions. Only accepts JPG images.
- Returns: A PrinterStatus enum indicating the printer’s status.
- Parameters:
- data: A Uint8List with the JPG image raw data.
- 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 type of barcode 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.
TODO #
- Pass image data from outside the MethodChannel to avoid payload size/speed limitations.
- Implement plugin tests.
- Standardize exceptions outputs.
- Print raw ESC/POS commands.