bx_btprinter 0.0.9
bx_btprinter: ^0.0.9 copied to clipboard
This Flutter plugin allows you to connect to a Bixolon printer via Bluetooth and send print commands. The files in the libs folder belong to Bixolon.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'webview.dart';
import 'package:bx_btprinter/btprinter.dart';
import 'package:flutter_dotenv/flutter_dotenv.dart';
Future<void> main() async{
await dotenv.load(fileName: '.env');
WidgetsFlutterBinding.ensureInitialized();
runApp(MyApp());
}
class MyApp extends StatefulWidget {
@override
_MyAppState createState() => _MyAppState();
}
class _MyAppState extends State<MyApp> {
final _btprinterPlugin = Btprinter();//플러그인 호출
@override
void initState() {
super.initState();
initBle();// 블루투스 연결
}
void initBle() async {
// Request BLE permissions from MainActivity
await _getBle();
}
Future<void> _getBle() async {
String? value;
try {
// value = await platform.invokeMethod('getBle');
value = await _btprinterPlugin.getBtPermission();
} on PlatformException catch (e) {
value = 'native code error: ${e.message}';
}
//print(value);
}
@override
Widget build(BuildContext context) {
SystemChrome.setEnabledSystemUIMode(SystemUiMode.immersive);//풀스크린 설정, 화면 로테이션 없음
return MaterialApp(
debugShowCheckedModeBanner: false,
home: Scaffold(
backgroundColor: Colors.white, // 배경을 흰색으로 설정
body: WebViewContainer(),
),
);
}
}