tsc_blue_print 0.1.1 copy "tsc_blue_print: ^0.1.1" to clipboard
tsc_blue_print: ^0.1.1 copied to clipboard

Es un plugin, desarrollado para flutter con compatibilidad para Android y IOS para poder interactuar con las impresoras de ticket marca TSC.

tsc_blue_print #

Impresión TSC Bluetooth / Network

Decripcion #

Es un plug-in package, desarrollado para flutter con compatibilidad para Android y IOS para poder interactuar con las impresoras de ticket marca TSC.

Instalar #

flutter pub add tsc_blue_print

Ejemplo #

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

  String device = "";
  bool connected = false;
  List availableBluetoothDevices = [];

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

  Future<void> initPlatformState() async {
    String platformVersion;
    try {
      platformVersion = await _tscBluePrintPlugin.getPlatformVersion() ??
          'Unknown platform version';
    } on PlatformException {
      platformVersion = 'Failed to get platform version.';
    }

    if (!mounted) return;

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

  Future<void> getBluetooth() async {
    final List? bluetooths = await BluetoothThermalPrinter.getBluetooths;
    print("Print $bluetooths");
    setState(() {
      availableBluetoothDevices = bluetooths == null ? [] : bluetooths;
    });
  }

  Future<void> setConnect(String mac) async {
    //final String? result = await BluetoothThermalPrinter.connect(mac);
    device = mac;
    print("state conneected $device");
    setState(() {
      connected = true;
    });
  }

  Future<void> inbound() async {
    String printMessage;
    String idAddress = device;
    print(idAddress);
    try {
      printMessage = await _tscBluePrintPlugin.printBlue(
          ipAddress: device,
          widthPaper: 47,
          heightPaper: 25,
          numero: '0001',
          tara: "0.58",
          bruto: "11.81",
          peso: "11.23",
          vendor: "PEC. SAN FRANCISCO(MAIZALES)",
          expiryDate: '03/22/2020',
          productCode: '000000001',
          productName: 'HUEVO PARDO');
    } on PlatformException {
      printMessage = 'Failed to communcate with this printer. ';
    }

    print(printMessage);
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Scaffold(
          appBar: AppBar(
            title: Text("Test de Impresion TSC",
                style: TextStyle(color: Colors.brown)),
            centerTitle: true,
            backgroundColor: Colors.white,
            iconTheme: IconThemeData(color: Colors.brown),
            actions: [],
          ),
          body: Container(
            padding: EdgeInsets.all(20),
            child: Column(
              crossAxisAlignment: CrossAxisAlignment.start,
              children: [
                Text("Search Paired Bluetooth"),
                TextButton(
                  onPressed: () {
                    this.getBluetooth();
                  },
                  child: Text("Search"),
                ),
                Container(
                  height: 200,
                  child: ListView.builder(
                    itemCount: availableBluetoothDevices.length > 0
                        ? availableBluetoothDevices.length
                        : 0,
                    itemBuilder: (context, index) {
                      return ListTile(
                        onTap: () {
                          String select = availableBluetoothDevices[index];
                          List list = select.split("#");
                          // String name = list[0];
                          String mac = list[1];
                          this.setConnect(mac);
                        },
                        title: Text('${availableBluetoothDevices[index]}'),
                        subtitle: Text("Click to connect"),
                      );
                    },
                  ),
                ),
                SizedBox(
                  height: 30,
                ),
                TextButton(
                  onPressed: connected ? this.inbound : null,
                  child: Text("Print"),
                ),
              ],
            ),
          ),
        ),
      ),
    );
  }
}
2
likes
110
pub points
56%
popularity

Publisher

unverified uploader

Es un plugin, desarrollado para flutter con compatibilidad para Android y IOS para poder interactuar con las impresoras de ticket marca TSC.

Homepage

Documentation

API reference

License

unknown (LICENSE)

Dependencies

flutter, plugin_platform_interface

More

Packages that depend on tsc_blue_print