universal_thermal_printer 1.0.0
universal_thermal_printer: ^1.0.0 copied to clipboard
Universal Thermal Printer SDK for Flutter — Bluetooth & Network (WiFi/LAN) ESC/POS thermal printer support with text, QR, barcode, images, and built-in remote license activation.
example/lib/main.dart
import 'package:flutter/material.dart';
import 'package:universal_thermal_printer/universal_thermal_printer.dart';
import 'app_controller.dart';
import 'screens/connect_screen.dart';
import 'screens/gallery_screen.dart';
/// Single shared controller for the whole demo.
final AppController controller = AppController();
void main() {
// ── License is handled internally — end users never type or see a key ──
// To unlock unlimited printing, developers pass ONLY a license key:
//
// LicenseManager.instance.configure(licenseKey: 'UTP-XXXX-XXXX-XXXX');
//
// (No Firebase details are ever needed here — the SDK already knows its
// backend.) With no key the SDK still works with a modest daily cap that is
// never surfaced to end users.
LicenseManager.instance.configure(appId: 'com.example.utp_demo');
runApp(const DemoApp());
}
class DemoApp extends StatelessWidget {
const DemoApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Universal Thermal Printer',
debugShowCheckedModeBanner: false,
theme: ThemeData(
colorSchemeSeed: const Color(0xFF3949AB),
useMaterial3: true,
brightness: Brightness.light,
),
darkTheme: ThemeData(
colorSchemeSeed: const Color(0xFF3949AB),
useMaterial3: true,
brightness: Brightness.dark,
),
home: const HomeShell(),
);
}
}
class HomeShell extends StatefulWidget {
const HomeShell({super.key});
@override
State<HomeShell> createState() => _HomeShellState();
}
class _HomeShellState extends State<HomeShell> {
int _index = 0;
@override
Widget build(BuildContext context) {
final pages = [
ConnectScreen(controller: controller),
GalleryScreen(controller: controller),
];
return Scaffold(
appBar: AppBar(
title: const Text('Universal Thermal Printer'),
actions: [
// Subtle positive indicator only — nothing is shown to end users
// about free/trial limits.
AnimatedBuilder(
animation: controller,
builder: (context, _) {
if (controller.licenseMode != LicenseMode.licensed) {
return const SizedBox.shrink();
}
return Padding(
padding: const EdgeInsets.only(right: 12),
child: Tooltip(
message: 'Licensed',
child: Icon(Icons.verified,
color: Theme.of(context).colorScheme.primary),
),
);
},
),
],
),
body: pages[_index],
bottomNavigationBar: NavigationBar(
selectedIndex: _index,
onDestinationSelected: (i) => setState(() => _index = i),
destinations: const [
NavigationDestination(
icon: Icon(Icons.print_outlined), label: 'Printer'),
NavigationDestination(
icon: Icon(Icons.dashboard_customize_outlined),
label: 'Templates'),
],
),
);
}
}