print_bartender 0.0.8 copy "print_bartender: ^0.0.8" to clipboard
print_bartender: ^0.0.8 copied to clipboard

PlatformWindows

0.0.7没上传依赖

example/lib/main.dart

import 'dart:convert';

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:flutter/services.dart';
import 'package:print_bartender/print_bartender.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  String _platformVersion = 'Unknown';
  final _printBartenderPlugin = PrintBartender();

  @override
  void initState() {
    super.initState();
    initPlatformState();
  }

  // Platform messages are asynchronous, so we initialize in an async method.
  Future<void> initPlatformState() async {
    String platformVersion;
    // Platform messages may fail, so we use a try/catch PlatformException.
    // We also handle the message potentially returning null.
    try {
      platformVersion =
          await _printBartenderPlugin.getPlatformVersion() ?? 'Unknown platform version';
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }

    // If the widget was removed from the tree while the asynchronous platform
    // message was in flight, we want to discard the reply rather than calling
    // setState to update our non-existent appearance.
    if (!mounted) return;

    setState(() {
      _platformVersion = platformVersion;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Center(
          child: Column(
            children: [
              Text('Running on: $_platformVersion\n'),
              ElevatedButton(
                onPressed: () async {
                  print(await PrintBartender().getDefaultPrinterName());
                  print(await PrintBartender().getPrinterList());
                  // return;"D:/work/test.btw"
                  var res = await PrintBartender().startPrint("D:/work/test你好.btw", json.encode([{"SN_KEY":"00000002469E","SN_ID":"https://hap.hegii.com/jump?state=productInfo-CQ602B00000B0160012506040028","WO_KEY":"SO:6001,CP-1259761","ITEM_KEY":"ITEM:6001,CQ602B00000B01,1","IS_PRINT":"Y","CREATE_DATE":"2025-06-05 21:53:27","PRINT_COUNT":1,"TRX_DATE":"2025-06-05 21:53:27","TRX_USER_KEY":"JX","SerialNum":null,"ITEM_DESC":"控制你的机盖板HQ601","ITEM_ID":"CQ602B00000B01","ITEM_COMBIANTION_NUM":"HQ602","ITEM_TYPE":"常规","F_CERAMIC_NUM":"无","F_WATER_CONSUME":"4.0L","F_PRODUCT_SIZE":"726*473*210mm","F_GROSS_WEIGHT":"5.6kg","F_NET_WEIGHT":"7.2kg","PRODUCT_DATE":"2025.06.04","PACK_QTY":"1套","ENFORCE_STANDARDS":"GB 4706.1-2005 GB 4706.53-2008","F_COUNTRY_CODE":"6970322942934","SN":"CQ602B00000B0160012506040028","COMPANY_NAME":"佛山市恒洁卫浴有限公司","COMPANY_ADDRESS":"佛山市三水区乐平镇中心科技工业区","COMPANY_IT":"WWW.HEGII.COM","F_PRODUCT_NUM":"HQ602","F_LAST_FOUR":"0028","Times":2,"entityId":"A09282506030446"}]),printerName: "Microsoft Print to PDF");
                  print(res);
                },
                child: Text("打印")
              )
            ],
          ),
        ),
      ),
    );
  }
}
1
likes
120
points
136
downloads

Publisher

unverified uploader

Weekly Downloads

0.0.7没上传依赖

Documentation

API reference

License

unknown (license)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on print_bartender