fl_print_pl 0.0.3 fl_print_pl: ^0.0.3 copied to clipboard
汉印打印机插件 仅支持安卓,因为打印数据不同,需下载自行修改
import 'package:flutter/material.dart';
import 'dart:async';
import 'package:flutter/services.dart';
import 'package:fl_print_pl/fl_print_pl.dart';
void main() => runApp(MyApp());
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
@override
void initState() {
FlPrintPl.init();
super.initState();
}
@override
void dispose() {
super.dispose();
FlPrintPl.dispose();
}
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: const Text('打印数据'),
),
body: Container(
padding: EdgeInsets.all(16),
child: Column(
children: <Widget>[
InkWell(
child: Container(height: 50, child: Text("点击获取蓝牙数据")),
onTap: () {
FlPrintPl.getBlueData();
},
),
InkWell(
child: Container(height: 50, child: Text("点击进行蓝牙连接")),
onTap: () {},
),
Container(
height: 50,
width: double.infinity,
child: RaisedButton(
color: Colors.white,
child: Text('点击进行打印机搜索'),
onPressed: () async {
await FlPrintPl.searchBlue();
},
),
)
],
),
),
),
);
}
}