diff --git a/example/blue/android/app/build.gradle b/example/blue/android/app/build.gradle index 9be8e53..55deb1b 100644 --- a/example/blue/android/app/build.gradle +++ b/example/blue/android/app/build.gradle @@ -26,7 +26,7 @@ apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" android { - compileSdkVersion 28 + compileSdkVersion 33 sourceSets { main.java.srcDirs += 'src/main/kotlin' @@ -40,7 +40,7 @@ android { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.example.blue" minSdkVersion 21 - targetSdkVersion 28 + targetSdkVersion 33 versionCode flutterVersionCode.toInteger() versionName flutterVersionName testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" diff --git a/example/blue/android/app/src/main/AndroidManifest.xml b/example/blue/android/app/src/main/AndroidManifest.xml index ebf0490..43f5bf7 100644 --- a/example/blue/android/app/src/main/AndroidManifest.xml +++ b/example/blue/android/app/src/main/AndroidManifest.xml @@ -1,21 +1,50 @@ +xmlns:tools="http://schemas.android.com/tools" + package="com.example.blue" > + + + + + + + + + + + + + diff --git a/example/blue/android/app/src/main/kotlin/com/example/blue/MainActivity.kt b/example/blue/android/app/src/main/kotlin/com/example/blue/MainActivity.kt index a32b948..09806c7 100644 --- a/example/blue/android/app/src/main/kotlin/com/example/blue/MainActivity.kt +++ b/example/blue/android/app/src/main/kotlin/com/example/blue/MainActivity.kt @@ -1,12 +1,6 @@ package com.example.blue -import androidx.annotation.NonNull; import io.flutter.embedding.android.FlutterActivity -import io.flutter.embedding.engine.FlutterEngine -import io.flutter.plugins.GeneratedPluginRegistrant class MainActivity: FlutterActivity() { - override fun configureFlutterEngine(@NonNull flutterEngine: FlutterEngine) { - GeneratedPluginRegistrant.registerWith(flutterEngine); - } } diff --git a/example/blue/android/build.gradle b/example/blue/android/build.gradle index 3100ad2..8fcd5e6 100644 --- a/example/blue/android/build.gradle +++ b/example/blue/android/build.gradle @@ -1,12 +1,12 @@ buildscript { - ext.kotlin_version = '1.3.50' + ext.kotlin_version = '1.8.0' repositories { google() jcenter() } dependencies { - classpath 'com.android.tools.build:gradle:3.5.0' + classpath 'com.android.tools.build:gradle:7.2.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" } } @@ -26,6 +26,6 @@ subprojects { project.evaluationDependsOn(':app') } -task clean(type: Delete) { +tasks.register("clean", Delete) { delete rootProject.buildDir } diff --git a/example/blue/android/gradle/wrapper/gradle-wrapper.properties b/example/blue/android/gradle/wrapper/gradle-wrapper.properties index 296b146..cfe88f6 100644 --- a/example/blue/android/gradle/wrapper/gradle-wrapper.properties +++ b/example/blue/android/gradle/wrapper/gradle-wrapper.properties @@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.2-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-7.6.1-all.zip diff --git a/example/blue/lib/main.dart b/example/blue/lib/main.dart index 108d463..90ef29f 100644 --- a/example/blue/lib/main.dart +++ b/example/blue/lib/main.dart @@ -1,6 +1,7 @@ import 'dart:io'; import 'dart:typed_data'; import 'package:intl/intl.dart'; +import 'package:permission_handler/permission_handler.dart'; import 'package:qr_flutter/qr_flutter.dart'; import 'package:path_provider/path_provider.dart'; import 'package:flutter/services.dart'; @@ -51,7 +52,13 @@ class _MyHomePageState extends State { }); } - void _startScanDevices() { + void _startScanDevices() async { + await [ + Permission.location, + Permission.bluetooth, + Permission.bluetoothConnect, + Permission.bluetoothScan, + ].request(); setState(() { _devices = []; }); @@ -62,8 +69,7 @@ class _MyHomePageState extends State { printerManager.stopScan(); } - Future> demoReceipt( - PaperSize paper, CapabilityProfile profile) async { + Future> demoReceipt(PaperSize paper, CapabilityProfile profile) async { final Generator ticket = Generator(paper, profile); List bytes = []; @@ -81,56 +87,42 @@ class _MyHomePageState extends State { ), linesAfter: 1); - bytes += ticket.text('889 Watson Lane', - styles: PosStyles(align: PosAlign.center)); - bytes += ticket.text('New Braunfels, TX', - styles: PosStyles(align: PosAlign.center)); - bytes += ticket.text('Tel: 830-221-1234', - styles: PosStyles(align: PosAlign.center)); - bytes += ticket.text('Web: www.example.com', - styles: PosStyles(align: PosAlign.center), linesAfter: 1); + bytes += ticket.text('889 Watson Lane', styles: PosStyles(align: PosAlign.center)); + bytes += ticket.text('New Braunfels, TX', styles: PosStyles(align: PosAlign.center)); + bytes += ticket.text('Tel: 830-221-1234', styles: PosStyles(align: PosAlign.center)); + bytes += ticket.text('Web: www.example.com', styles: PosStyles(align: PosAlign.center), linesAfter: 1); bytes += ticket.hr(); bytes += ticket.row([ PosColumn(text: 'Qty', width: 1), PosColumn(text: 'Item', width: 7), - PosColumn( - text: 'Price', width: 2, styles: PosStyles(align: PosAlign.right)), - PosColumn( - text: 'Total', width: 2, styles: PosStyles(align: PosAlign.right)), + PosColumn(text: 'Price', width: 2, styles: PosStyles(align: PosAlign.right)), + PosColumn(text: 'Total', width: 2, styles: PosStyles(align: PosAlign.right)), ]); bytes += ticket.row([ PosColumn(text: '2', width: 1), PosColumn(text: 'ONION RINGS', width: 7), - PosColumn( - text: '0.99', width: 2, styles: PosStyles(align: PosAlign.right)), - PosColumn( - text: '1.98', width: 2, styles: PosStyles(align: PosAlign.right)), + PosColumn(text: '0.99', width: 2, styles: PosStyles(align: PosAlign.right)), + PosColumn(text: '1.98', width: 2, styles: PosStyles(align: PosAlign.right)), ]); bytes += ticket.row([ PosColumn(text: '1', width: 1), PosColumn(text: 'PIZZA', width: 7), - PosColumn( - text: '3.45', width: 2, styles: PosStyles(align: PosAlign.right)), - PosColumn( - text: '3.45', width: 2, styles: PosStyles(align: PosAlign.right)), + PosColumn(text: '3.45', width: 2, styles: PosStyles(align: PosAlign.right)), + PosColumn(text: '3.45', width: 2, styles: PosStyles(align: PosAlign.right)), ]); bytes += ticket.row([ PosColumn(text: '1', width: 1), PosColumn(text: 'SPRING ROLLS', width: 7), - PosColumn( - text: '2.99', width: 2, styles: PosStyles(align: PosAlign.right)), - PosColumn( - text: '2.99', width: 2, styles: PosStyles(align: PosAlign.right)), + PosColumn(text: '2.99', width: 2, styles: PosStyles(align: PosAlign.right)), + PosColumn(text: '2.99', width: 2, styles: PosStyles(align: PosAlign.right)), ]); bytes += ticket.row([ PosColumn(text: '3', width: 1), PosColumn(text: 'CRUNCHY STICKS', width: 7), - PosColumn( - text: '0.85', width: 2, styles: PosStyles(align: PosAlign.right)), - PosColumn( - text: '2.55', width: 2, styles: PosStyles(align: PosAlign.right)), + PosColumn(text: '0.85', width: 2, styles: PosStyles(align: PosAlign.right)), + PosColumn(text: '2.55', width: 2, styles: PosStyles(align: PosAlign.right)), ]); bytes += ticket.hr(); @@ -155,35 +147,21 @@ class _MyHomePageState extends State { bytes += ticket.hr(ch: '=', linesAfter: 1); bytes += ticket.row([ - PosColumn( - text: 'Cash', - width: 7, - styles: PosStyles(align: PosAlign.right, width: PosTextSize.size2)), - PosColumn( - text: '\$15.00', - width: 5, - styles: PosStyles(align: PosAlign.right, width: PosTextSize.size2)), + PosColumn(text: 'Cash', width: 7, styles: PosStyles(align: PosAlign.right, width: PosTextSize.size2)), + PosColumn(text: '\$15.00', width: 5, styles: PosStyles(align: PosAlign.right, width: PosTextSize.size2)), ]); bytes += ticket.row([ - PosColumn( - text: 'Change', - width: 7, - styles: PosStyles(align: PosAlign.right, width: PosTextSize.size2)), - PosColumn( - text: '\$4.03', - width: 5, - styles: PosStyles(align: PosAlign.right, width: PosTextSize.size2)), + PosColumn(text: 'Change', width: 7, styles: PosStyles(align: PosAlign.right, width: PosTextSize.size2)), + PosColumn(text: '\$4.03', width: 5, styles: PosStyles(align: PosAlign.right, width: PosTextSize.size2)), ]); bytes += ticket.feed(2); - bytes += ticket.text('Thank you!', - styles: PosStyles(align: PosAlign.center, bold: true)); + bytes += ticket.text('Thank you!', styles: PosStyles(align: PosAlign.center, bold: true)); final now = DateTime.now(); final formatter = DateFormat('MM/dd/yyyy H:m'); final String timestamp = formatter.format(now); - bytes += ticket.text(timestamp, - styles: PosStyles(align: PosAlign.center), linesAfter: 2); + bytes += ticket.text(timestamp, styles: PosStyles(align: PosAlign.center), linesAfter: 2); // Print QR Code from image // try { @@ -213,13 +191,11 @@ class _MyHomePageState extends State { return bytes; } - Future> testTicket( - PaperSize paper, CapabilityProfile profile) async { + Future> testTicket(PaperSize paper, CapabilityProfile profile) async { final Generator generator = Generator(paper, profile); List bytes = []; - bytes += generator.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'); + bytes += generator.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'); // bytes += generator.text('Special 1: àÀ èÈ éÉ ûÛ üÜ çÇ ôÔ', // styles: PosStyles(codeTable: PosCodeTable.westEur)); // bytes += generator.text('Special 2: blåbærgrød', @@ -227,14 +203,10 @@ class _MyHomePageState extends State { bytes += generator.text('Bold text', styles: PosStyles(bold: true)); bytes += generator.text('Reverse text', styles: PosStyles(reverse: true)); - bytes += generator.text('Underlined text', - styles: PosStyles(underline: true), linesAfter: 1); - bytes += - generator.text('Align left', styles: PosStyles(align: PosAlign.left)); - bytes += generator.text('Align center', - styles: PosStyles(align: PosAlign.center)); - bytes += generator.text('Align right', - styles: PosStyles(align: PosAlign.right), linesAfter: 1); + bytes += generator.text('Underlined text', styles: PosStyles(underline: true), linesAfter: 1); + bytes += generator.text('Align left', styles: PosStyles(align: PosAlign.left)); + bytes += generator.text('Align center', styles: PosStyles(align: PosAlign.center)); + bytes += generator.text('Align right', styles: PosStyles(align: PosAlign.right), linesAfter: 1); bytes += generator.row([ PosColumn( @@ -298,8 +270,7 @@ class _MyHomePageState extends State { // await printerManager.printTicket(await testTicket(paper)); // DEMO RECEIPT - final PosPrintResult res = - await printerManager.printTicket((await demoReceipt(paper, profile))); + final PosPrintResult res = await printerManager.printTicket((await demoReceipt(paper, profile))); showToast(res.msg); } diff --git a/example/blue/pubspec.yaml b/example/blue/pubspec.yaml index f7e11c7..feeff9c 100644 --- a/example/blue/pubspec.yaml +++ b/example/blue/pubspec.yaml @@ -6,20 +6,19 @@ environment: sdk: ">=2.12.0 <3.0.0" dependencies: - flutter: - sdk: flutter + charset_converter: ^2.0.0 cupertino_icons: ^1.0.3 - oktoast: ^3.0.0 - image: ^3.0.2 esc_pos_bluetooth: path: ../../ esc_pos_utils: ^1.1.0 - # esc_pos_utils: - # path: ../../../esc_pos_utils - charset_converter: ^2.0.0 + flutter: + sdk: flutter + image: ^3.0.2 intl: ^0.17.0 - qr_flutter: ^4.0.0 + oktoast: ^3.0.0 path_provider: ^2.0.2 + permission_handler: ^10.4.3 + qr_flutter: ^4.0.0 dev_dependencies: flutter_test: