show method
Shows the floating printing indicator.
Implementation
void show(BuildContext? context) {
if (!PrinterSdkConfig.showPrintLoader) return;
if (context == null || _isShowing) return;
final OverlayState? overlay = Overlay.maybeOf(context, rootOverlay: true);
if (overlay == null) return;
_isShowing = true;
_overlayEntry = OverlayEntry(
builder: (_) => Positioned(
right: 16,
bottom: 16,
child: Material(
color: Colors.transparent,
child: Container(
padding: const EdgeInsets.symmetric(horizontal: 14, vertical: 10),
decoration: BoxDecoration(
color: PrinterSdkConfig.surfaceColor,
borderRadius: BorderRadius.circular(30),
border: Border.all(color: PrinterSdkConfig.borderColor),
boxShadow: <BoxShadow>[
BoxShadow(
color: Colors.black.withValues(alpha: 0.08),
blurRadius: 16,
offset: const Offset(0, 6),
),
],
),
child: Row(
mainAxisSize: MainAxisSize.min,
children: <Widget>[
SizedBox(
width: 32,
height: 32,
child: FutureBuilder<ByteData>(
future: _loadAnimation(),
builder: (BuildContext context,
AsyncSnapshot<ByteData> snapshot) {
if (!snapshot.hasData) {
return Center(
child: CircularProgressIndicator(
strokeWidth: 2.2,
color: PrinterSdkConfig.primaryColor,
),
);
}
return Lottie.memory(
snapshot.data!.buffer.asUint8List(),
repeat: true,
fit: BoxFit.contain,
);
},
),
),
const SizedBox(width: 8),
Text(
PrinterSdkConfig.loadingLabel,
style: TextStyle(
color: PrinterSdkConfig.textPrimaryColor,
fontSize: 12.5,
fontWeight: FontWeight.w600,
),
),
],
),
),
),
),
);
try {
overlay.insert(_overlayEntry!);
} catch (_) {
_isShowing = false;
_overlayEntry = null;
}
}