Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions lib/core/csv/result_grid_csv.dart
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
library;

import 'dart:io';
import 'dart:isolate';

String escapeCsvField(String s) {
final needsQuotes = s.contains(',') ||
Expand All @@ -27,8 +26,9 @@ String formatCsvDataRow(List<String> row, int columnCount) {

/// One line per row; pads short rows with empty cells to [columns.length].
///
/// Prefer [resultGridAsCsvAsync] for large grids on the UI isolate, and
/// [writeResultGridCsv] when writing to a file.
/// For large grids use [writeResultGridCsv] when writing to a file;
/// `DataExportService.formatAsync` runs this off the UI isolate for the
/// clipboard.
String resultGridAsCsv(List<String> columns, List<List<String>> rows) {
final buf = StringBuffer();
buf.write(columns.map(escapeCsvField).join(','));
Expand All @@ -39,14 +39,6 @@ String resultGridAsCsv(List<String> columns, List<List<String>> rows) {
return buf.toString();
}

/// Builds CSV off the UI isolate so large grids do not freeze the main thread.
Future<String> resultGridAsCsvAsync(
List<String> columns,
List<List<String>> rows,
) {
return Isolate.run(() => resultGridAsCsv(columns, rows));
}

/// Streams CSV to [sink] without assembling the full document in memory.
Future<void> writeResultGridCsv(
IOSink sink, {
Expand Down
12 changes: 0 additions & 12 deletions test/core/csv/result_grid_csv_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,6 @@ void main() {
});
});

group('resultGridAsCsvAsync', () {
test('matches synchronous result off the UI isolate', () async {
const columns = ['a', 'b'];
const rows = [
['1', 'two,comma'],
['quote', 'say "hi"'],
];
final asyncCsv = await resultGridAsCsvAsync(columns, rows);
expect(asyncCsv, resultGridAsCsv(columns, rows));
});
});

group('writeResultGridCsv', () {
test('streams the same content as resultGridAsCsv', () async {
const columns = ['a', 'b'];
Expand Down
Loading