fl_print_pl 0.0.4 fl_print_pl: ^0.0.4 copied to clipboard
Chinese print printer plug-in only supports android, because the print data is different, you need to download their own modification
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();
},
),
)
],
),
),
),
);
}
}