gpos720_printer 0.0.4
gpos720_printer: ^0.0.4 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.
Instalation #
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();
}
Documumentation #
Methods: #
Future<String?> avancaLinha(int quantLinhas)
- Description: Adds line breaks to the current printout.
- Returns: An 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<String?> checarImpressora()
- Description: Checks the printer’s status.
- Returns: An PrinterStatus enum indicating the printer’s status.
- Throws: A PlatformException or a MissingPluginException.
Future<String?> fimImpressao()
- Description: Finalizes the printing queue.
- Returns: An PrinterStatus enum indicating the printer’s status.
- Throws: A PlatformException or a MissingPluginException.
Future<String?> imprimirCodigoDeBarra(String mensagem, int width, int height, BarcodeTypes barcodeType)
- Description: Prints various types of barcodes.
- Returns: An PrinterStatus enum indicating the printer’s status.
- Parameters:
- mensagem: A String specifying the desired data on the barcode.
- width: An Integer specifing the desired width.
- height: An Integer specifing the desired height.
- barcodeTypes: A BarcodeTypes enum specifing the desired barcode type.
- Throws: A PlatformException or a MissingPluginException.
Future<String?> imprimirImagem(Uint8List data, int width, int height, {AlignmentTypes align = AlignmentTypes.center})
- Description: Prints raw images.
- Returns: An PrinterStatus enum indicating the printer’s status.
- Parameters:
- data: A Uint8List with the image raw data.
- width: An Integer specifing the desired width.
- height: An Integer specifing the desired height.
- align (optional): An AlignmentTypes enum specifying the desired alignment. By default, align will be center.
- Throws: A PlatformException or a MissingPluginException.
imprimirTexto(String mensagem, {TextOptions? options, int size = defaultFontSize, Font? font, AlignmentTypes align = AlignmentTypes.left})
- Description: Prints text.
- Returns: An PrinterStatus enum indicating the printer’s status.
- Parameters:
- mensagem: A String with the desired text to be printed.
- options (optional): A TextOptions specifing if the text will be render as bold, italic or underlined.
- size (optional): An Integer specifing the desired font size.
- Font (optional): A Font specifing 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<String?> imprimirTodasFuncoes(Uint8List data, int width, int height)
- Description: Prints all printer functions.
- Returns: An PrinterStatus enum indicating the printer’s status.
- Parameters:
- data: A Uint8List with the image raw data.
- width: An Integer specifing the desired width.
- height: An Integer specifing the desired height.
- Throws: A PlatformException or a MissingPluginException.
Configutarion 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.
- Standarize exceptions outputs.
- Print raw ESC/POS commands.