renderSqliteTable function

String renderSqliteTable(
  1. List<String> columns,
  2. List<Map<String, Object?>> rows, {
  3. required int totalCount,
  4. required int offset,
  5. required int limit,
  6. required String table,
})

Renders a paged table plus the continuation note when more rows remain (omp's renderTable).

Implementation

String renderSqliteTable(
  List<String> columns,
  List<Map<String, Object?>> rows, {
  required int totalCount,
  required int offset,
  required int limit,
  required String table,
}) {
  final parts = [buildSqliteAsciiTable(columns, rows)];
  final shown = totalCount < offset + rows.length
      ? totalCount
      : offset + rows.length;
  if (shown < totalCount) {
    final remaining = totalCount - shown;
    final nextOffset = offset + rows.length;
    parts.add(
      truncateSqliteWidth(
        _replaceTabs(
          '[$remaining more rows; append '
          ':$table?limit=$limit&offset=$nextOffset to the database path to '
          'continue]',
        ),
        maxSqliteRenderWidth,
      ),
    );
  }
  return parts.join('\n');
}