sunmiconditionalimports 0.2.5 copy "sunmiconditionalimports: ^0.2.5" to clipboard
sunmiconditionalimports: ^0.2.5 copied to clipboard

PlatformAndroidweb
unlisted

A wrapper for the sunmi_printer_plus, sunmi_scanner, image, and sumup packages to use them conditionally based on the platform.

This package is a wrapper for the sunmi_printer_plus, sunmi_scanner, image, sumup, and qrcode_barcode_scanner packages. It provides a way to import these packages conditionally based on the platform. This is useful for when you want to use these packages on Android, while also deploying the same code to the web. Specifically made for usage with FlutterFlow, since FlutterFlow does not support conditional imports.

Features #

This package provides:

  • Conditional imports for the sunmi_printer_plus package for receipt printing
  • Conditional imports for the sunmi_scanner package for barcode scanning
  • Conditional imports for the qrcode_barcode_scanner package for external scanner devices
  • Image processing with transparency support and aspect ratio preservation (using the image package)
  • SumUp payment integration for processing card payments
  • Cross-platform compatibility for web and Android

Getting started #

Add the following to your pubspec.yaml file:

dependencies:
  sunmiconditionalimports: ^0.2.5

Usage #

import 'package:sunmiconditionalimports/sunmiconditionalimports.dart';

DO NOT import the other files directly, as they are not intended to be used directly. #

Use the following classes from this package:

Printing #

  • SunmiPrinter - example: SunmiPrinter.printText('Hello World')
  • SunmiPrintAlign - example: SunmiPrintAlign.center()
  • SunmiFontSize - example: SunmiFontSize.md()
  • ColumnMaker - example: ColumnMaker(text: 'Hello World', width: 10, align: SunmiPrintAlign.center())
  • Bitmap - example: Bitmap.fromProvider(NetworkImage('https://example.com/image.png'), 100)

Barcode Scanning #

  • SunmiScanner - For Sunmi device barcode scanning functionality
  • QRCodeScanner - For external QR code and barcode scanner devices

QRCodeScanner Example

// Initialize the QR code scanner with a callback
QRCodeScanner.initialize(
  onScannedCallback: (String scannedValue) {
    print('Scanned code: $scannedValue');
    // Process the scanned value here
  },
);

// Check if scanner is initialized
final isInitialized = QRCodeScanner.isInitialized();
print('Scanner initialized: $isInitialized');

// Dispose the scanner when done (e.g., in dispose method)
@override
void dispose() {
  QRCodeScanner.dispose();
  super.dispose();
}

Payment Processing #

  • Sumup - For SumUp payment processing
  • SumupPayment - For creating payment requests

SumUp Payment Example

// Initialize SumUp with your affiliate key
final initResult = await Sumup.init('YOUR_AFFILIATE_KEY');

// Login to SumUp
final loginResult = await Sumup.login();
if (!loginResult.status) {
  print('Login failed: ${loginResult.message}');
  return;
}

// Create a payment
final payment = SumupPayment(
  title: 'Purchase',
  total: 19.99,
  currency: 'EUR',
  saleItemsCount: 1,
  skipSuccessScreen: false,
);

// Create a payment request
final paymentRequest = SumupPaymentRequest(payment);

// Process the payment
final result = await Sumup.checkout(paymentRequest);

// Check the result
if (result.status) {
  print('Payment successful!');
  print('Transaction code: ${result.transactionCode}');
  print('Card type: ${result.cardType}');
} else {
  print('Payment failed: ${result.message}');
}

SunmiScanner Example

// Check if scanner is available
final isAvailable = await SunmiScanner.isScannerAvailable();

// Get scanner model
final scannerModel = await SunmiScanner.getScannerModel();

// Start scanning
await SunmiScanner.scan();

// Listen for scanned barcodes
SunmiScanner.onBarcodeScanned().listen((barcode) {
  print('Scanned barcode: $barcode');
});

// Stop scanning when done
await SunmiScanner.stop();
0
likes
130
points
163
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

A wrapper for the sunmi_printer_plus, sunmi_scanner, image, and sumup packages to use them conditionally based on the platform.

Homepage
Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter, http, image, qrcode_barcode_scanner, sumup, sunmi_printer_plus, sunmi_scanner

More

Packages that depend on sunmiconditionalimports