godex 1.0.0
godex: ^1.0.0 copied to clipboard
A dart package for communicating with and controlling Godex label printers.
import 'package:godex/godex.dart';
void main() {
final stopwatch = Stopwatch()..start();
Future.wait([printSticker()]);
print('printSticker() executed in ${stopwatch.elapsed}');
}
const String godexIP = "172.30.2.154";
const String imageFile = "example/sticker.png";
const widthMm = 100;
const heightMm = 200;
const gapMm = 3;
Future<bool> printSticker() async {
bool ret = false;
final gdx = GodexIP(godexIP);
final image = await Image.open(imageFile, heightMm: heightMm, dpi: 300);
if (image != null) {
if (await gdx.open()) {
await gdx.setup(PrintingMode.directThermal, PaperType.labelWithGap,
heightMm.toInt(), widthMm.toInt(), gapMm.toInt(),
blackness: 14);
await gdx.beginLabel();
await gdx.drawImage(image);
ret = await gdx.endLabel();
await gdx.close();
}
}
return ret;
}