Skip to content

Commit 1eb04b3

Browse files
authored
Avoid cumbersome formatter workaround (#6573)
If a list shouldn't be formatted with one element on each line, a single EOL-comment inside is enough to disable the formatter. Much simpler.
1 parent 5e88f94 commit 1eb04b3

File tree

1 file changed

+4
-15
lines changed

1 file changed

+4
-15
lines changed

packages/flutter_markdown/test/image_test_mocks.dart

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// found in the LICENSE file.
44

55
import 'dart:async';
6-
import 'dart:convert';
76
import 'dart:io';
87

98
import 'package:mockito/mockito.dart';
@@ -69,25 +68,15 @@ MockHttpClient createMockImageHttpClient(SecurityContext? _) {
6968
return client;
7069
}
7170

72-
// This string represents the hexidecial bytes of a transparent image. A
73-
// string is used to make the visual representation of the data compact. A
74-
// List<int> of the same data requires over 60 lines in a source file with
75-
// each element in the array on a single line.
76-
const String _imageBytesAsString = '''
71+
// A list of integers that can be consumed as image data in a stream.
72+
final List<int> _transparentImage = <int>[
73+
// Image bytes.
7774
0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49,
7875
0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x08, 0x06,
7976
0x00, 0x00, 0x00, 0x1F, 0x15, 0xC4, 0x89, 0x00, 0x00, 0x00, 0x0A, 0x49, 0x44,
8077
0x41, 0x54, 0x78, 0x9C, 0x63, 0x00, 0x01, 0x00, 0x00, 0x05, 0x00, 0x01, 0x0D,
8178
0x0A, 0x2D, 0xB4, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4E, 0x44, 0xAE,
82-
''';
83-
84-
// Convert the string representing the hexidecimal bytes in the image into
85-
// a list of integers that can be consumed as image data in a stream.
86-
final List<int> _transparentImage = const LineSplitter()
87-
.convert(_imageBytesAsString.replaceAllMapped(
88-
RegExp(r' *0x([A-F0-9]{2}),? *\n? *'), (Match m) => '${m[1]}\n'))
89-
.map<int>((String b) => int.parse(b, radix: 16))
90-
.toList();
79+
];
9180

9281
List<int> getTestImageData() {
9382
return _transparentImage;

0 commit comments

Comments
 (0)