Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,17 +1,20 @@
# Nyx Printer

# Nyx Printer

Flutter Plugin that connect to Nyx devices Printer such as NB55.


## Installation

Install Nyx Printer with pub

```bash
flutter pub add nyx_printer
```

![Receipt](https://raw.githubusercontent.com/Aladdin16659/NyxPrinter/main/example/images/receipt.jpeg)


## Print Image

```dart
Expand All @@ -24,7 +27,6 @@ import 'package:nyx_printer/nyx_printer.dart';
await _nyxPrinterPlugin.printImage(image.buffer.asUint8List());
}
```

## Print Text

```dart
Expand All @@ -40,7 +42,6 @@ import 'package:nyx_printer/nyx_printer.dart';
);
}
```

## Print QR

```dart
Expand All @@ -52,8 +53,7 @@ import 'package:nyx_printer/nyx_printer.dart';
);
}
```

## Print Barcode
## Print QR

```dart
Future<void> printBarcode() async {
Expand All @@ -65,7 +65,9 @@ import 'package:nyx_printer/nyx_printer.dart';
}
```


## License

[MIT](https://github.com/Aladdin16659/NyxPrinter/blob/main/LICENSE)
Copyright (c) 2023 ALADDIN SID AHMED

50 changes: 34 additions & 16 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,34 +22,52 @@ rootProject.allprojects {
apply plugin: 'com.android.library'

android {
compileSdkVersion 31

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
if (project.android.hasProperty("namespace")) {
namespace = "net.nyx.nyxprinter.nyx_printer"
}

compileSdk = 34

defaultConfig {
minSdkVersion 16
targetSdkVersion 34
versionCode 1
versionName "1.0"
}

dependencies {
implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.mockito:mockito-core:5.0.0'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'org.aspectj:aspectjrt:1.9.6'
implementation 'com.jakewharton.timber:timber:4.7.1'
sourceSets {
main {
jniLibs.srcDirs = ['libs']
aidl.srcDirs = ['src/main/aidl']
}
}

compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}

buildFeatures {
aidl true
}

testOptions {
unitTests.all {
testLogging {
events "passed", "skipped", "failed", "standardOut", "standardError"
outputs.upToDateWhen {false}
showStandardStreams = true
events "passed", "skipped", "failed", "standardOut", "standardError"
outputs.upToDateWhen {false}
showStandardStreams = true
}
}
}
}

dependencies {
implementation fileTree(include: ['*.jar', '*.aar'], dir: 'libs')
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.mockito:mockito-core:5.0.0'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'org.aspectj:aspectjrt:1.9.6'
implementation 'com.jakewharton.timber:timber:4.7.1'
}
2 changes: 2 additions & 0 deletions android/gradle.properties
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
android.useAndroidX=true
android.enableJetifier=true
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;


/** NyxPrinterPlugin */
public class NyxPrinterPlugin implements FlutterPlugin, MethodCallHandler {
/// The MethodChannel that will the communication between Flutter and native Android
Expand Down
15 changes: 0 additions & 15 deletions lib/nyx_printer.dart
Original file line number Diff line number Diff line change
Expand Up @@ -5,40 +5,25 @@ import 'nyx_text_format.dart';
export 'nyx_text_format.dart';

class NyxPrinter {
/// [getVersion] will return printer version number.
/// success result is 0.
Future<int?> getVersion() {
return NyxPrinterPlatform.instance.getVersion();
}

/// [printText] will print text
/// to format text you can use [NyxTextFormat] to set font size or font style ...ext
/// success result is 0.
Future<int?> printText(String text, {NyxTextFormat? textFormat}) {
return NyxPrinterPlatform.instance
.printText(text, textFormat ?? NyxTextFormat());
}

/// [printBarcode] will print QR and you can set width and height.
/// default width is 300
/// default height is 160
/// success result is 0.
Future<int?> printBarcode(String text, {int? width, int? height}) {
return NyxPrinterPlatform.instance
.printBarcode(text, width ?? 300, height ?? 160);
}

/// [printQrCode] will print QR and you can set width and height.
/// default width is 300
/// default height is 300,
/// success result is 0.
Future<int?> printQrCode(String text, {int? width, int? height}) {
return NyxPrinterPlatform.instance
.printQrCode(text, width ?? 300, height ?? 300);
}

/// [printImage] will print only png images
/// success result is 0.
Future<int?> printImage(Uint8List bytes) {
return NyxPrinterPlatform.instance.printBitmap(bytes);
}
Expand Down