posprinter_thermal 0.1.0
posprinter_thermal: ^0.1.0 copied to clipboard
Premium Flutter SDK for Bluetooth and USB thermal printers: branded connection screens, paired-device discovery and ESC/POS test printing.
import 'package:flutter/material.dart';
import 'package:posprinter_thermal/pos_printer_sdk.dart';
Future<void> main() async {
WidgetsFlutterBinding.ensureInitialized();
await PrinterSdk.initialize(
primaryColor: const Color(0xFF0F766E),
appBarTitle: 'Printer Settings',
);
runApp(const ExampleApp());
}
class ExampleApp extends StatelessWidget {
const ExampleApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Printer SDK Example',
debugShowCheckedModeBanner: false,
theme: ThemeData(
useMaterial3: true,
colorScheme: ColorScheme.fromSeed(
seedColor: PrinterSdkConfig.primaryColor,
),
scaffoldBackgroundColor: PrinterSdkConfig.backgroundColor,
),
home: const HomePage(),
);
}
}
/// Tiny landing page that demonstrates how to launch the SDK screen.
class HomePage extends StatelessWidget {
const HomePage({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Center(
child: ConstrainedBox(
constraints: const BoxConstraints(maxWidth: 420),
child: Padding(
padding: const EdgeInsets.all(24),
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: <Widget>[
Container(
width: 72,
height: 72,
decoration: BoxDecoration(
color: PrinterSdkConfig.primaryColor,
borderRadius: BorderRadius.circular(20),
),
child: const Icon(
Icons.print_rounded,
color: Colors.white,
size: 36,
),
),
const SizedBox(height: 20),
Text(
'Thermal Printer SDK',
style: TextStyle(
fontSize: 22,
fontWeight: FontWeight.w700,
color: PrinterSdkConfig.textPrimaryColor,
),
),
const SizedBox(height: 8),
Text(
'Connect a Bluetooth or USB receipt printer, choose the '
'paper size and send a test page.',
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 13,
height: 1.45,
color: PrinterSdkConfig.textSecondaryColor,
),
),
const SizedBox(height: 24),
FilledButton.icon(
onPressed: () {
Navigator.of(context).push(
MaterialPageRoute<void>(
builder: (_) => const CommonPrinterSettingScreen(),
),
);
},
icon: const Icon(Icons.settings_rounded),
label: const Text('Open printer settings'),
style: FilledButton.styleFrom(
backgroundColor: PrinterSdkConfig.primaryColor,
minimumSize: const Size.fromHeight(48),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(12),
),
),
),
],
),
),
),
),
),
);
}
}