printTextFormatted method

  1. @override
Future<PrintResult> printTextFormatted(
  1. String text, {
  2. TextAlignment alignment = TextAlignment.left,
  3. FontAttributes fontAttributes = const FontAttributes(),
  4. int fontWidth = 0,
  5. int fontHeight = 0,
  6. int fontType = 0,
  7. bool cutPaper = true,
})
override

Imprime texto com formatação

Implementation

@override
Future<PrintResult> printTextFormatted(
  String text, {
  TextAlignment alignment = TextAlignment.left,
  FontAttributes fontAttributes = const FontAttributes(),
  int fontWidth = 0,
  int fontHeight = 0,
  int fontType = 0,
  bool cutPaper = true,
}) async {
  final result = await methodChannel.invokeMethod<Map>('printTextFormatted', {
    'text': text,
    'alignment': alignment.value,
    'fontAttributes': fontAttributes.toValue(),
    'fontWidth': fontWidth,
    'fontHeight': fontHeight,
    'fontType': fontType,
    'cutPaper': cutPaper,
  });

  if (result == null) {
    return const PrintResult(success: false, resultCode: -1);
  }

  return PrintResult.fromMap(result);
}