printRow static method

Future<String?> printRow({
  1. required List<SunmiColumn> cols,
})

Prints a row of columns with specified text, width, and styles.

cols: A list of SunmiColumn objects representing the row content.

Returns a String indicating the result of the operation, or null.

Implementation

static Future<String?> printRow({required List<SunmiColumn> cols}) async {
  List<List<dynamic>> separateProperties(List<SunmiColumn> columns) {
    List<String> textList = [];
    List<int> widthList = [];
    List<Map?> styleList = [];

    for (var column in columns) {
      textList.add(column.text);
      widthList.add(column.width);
      styleList.add(column.style?.toMap());
    }

    return [textList, widthList, styleList];
  }

  List<List<dynamic>> separatedProperties = separateProperties(cols);
  return await SunmiPrinterPlusPlatform.instance.printRow(
      text: separatedProperties[0],
      width: separatedProperties[1],
      style: separatedProperties[2]);
}