printRow static method

Future<void> printRow({
  1. List<ColumnMaker>? cols,
})

printRow

This method will print a row based in a list of ColumnMaker.

Implementation

static Future<void> printRow({List<ColumnMaker>? cols}) async {
  final isSumValid = cols!.fold(0, (int sum, col) => sum + col.width!) == 12;
  if (!isSumValid) {
    throw Exception('Total columns width must be equal to 12');
  }
  final _jsonCols = List<Map<String, String>>.from(
      cols.map<Map<String, String>>((ColumnMaker col) => col.toJson()));
  Map<String, dynamic> arguments = <String, dynamic>{
    "cols": json.encode(_jsonCols)
  };
  await _channel.invokeMethod("PRINT_ROW", arguments);
}