From ea8bc863862f3803df644dc86b4769c1190b3831 Mon Sep 17 00:00:00 2001 From: "Lasse R.H. Nielsen" Date: Fri, 19 Apr 2024 16:10:53 +0200 Subject: [PATCH 1/3] Avoid cumbersome formatter workaround 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. --- .../test/image_test_mocks.dart | 18 ++++-------------- 1 file changed, 4 insertions(+), 14 deletions(-) diff --git a/packages/flutter_markdown/test/image_test_mocks.dart b/packages/flutter_markdown/test/image_test_mocks.dart index 1cd56219c1a7..507b782645d6 100644 --- a/packages/flutter_markdown/test/image_test_mocks.dart +++ b/packages/flutter_markdown/test/image_test_mocks.dart @@ -69,25 +69,15 @@ MockHttpClient createMockImageHttpClient(SecurityContext? _) { return client; } -// This string represents the hexidecial bytes of a transparent image. A -// string is used to make the visual representation of the data compact. A -// List of the same data requires over 60 lines in a source file with -// each element in the array on a single line. -const String _imageBytesAsString = ''' +// A list of integers that can be consumed as image data in a stream. +final List _transparentImage = [ + // Image bytes. 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x08, 0x06, 0x00, 0x00, 0x00, 0x1F, 0x15, 0xC4, 0x89, 0x00, 0x00, 0x00, 0x0A, 0x49, 0x44, 0x41, 0x54, 0x78, 0x9C, 0x63, 0x00, 0x01, 0x00, 0x00, 0x05, 0x00, 0x01, 0x0D, 0x0A, 0x2D, 0xB4, 0x00, 0x00, 0x00, 0x00, 0x49, 0x45, 0x4E, 0x44, 0xAE, - '''; - -// Convert the string representing the hexidecimal bytes in the image into -// a list of integers that can be consumed as image data in a stream. -final List _transparentImage = const LineSplitter() - .convert(_imageBytesAsString.replaceAllMapped( - RegExp(r' *0x([A-F0-9]{2}),? *\n? *'), (Match m) => '${m[1]}\n')) - .map((String b) => int.parse(b, radix: 16)) - .toList(); +]; List getTestImageData() { return _transparentImage; From f0fd0d46ffefd0426c4a5b6f46bcd673b18284b8 Mon Sep 17 00:00:00 2001 From: "Lasse R.H. Nielsen" Date: Wed, 22 May 2024 12:33:55 +0200 Subject: [PATCH 2/3] Remove now unused import. --- packages/flutter_markdown/test/image_test_mocks.dart | 1 - 1 file changed, 1 deletion(-) diff --git a/packages/flutter_markdown/test/image_test_mocks.dart b/packages/flutter_markdown/test/image_test_mocks.dart index 507b782645d6..2be1a3f6aa8b 100644 --- a/packages/flutter_markdown/test/image_test_mocks.dart +++ b/packages/flutter_markdown/test/image_test_mocks.dart @@ -3,7 +3,6 @@ // found in the LICENSE file. import 'dart:async'; -import 'dart:convert'; import 'dart:io'; import 'package:mockito/mockito.dart'; From ba5220973a84114aad7dcf7dd2816cb92b2529a5 Mon Sep 17 00:00:00 2001 From: "Lasse R.H. Nielsen" Date: Wed, 22 May 2024 15:50:48 +0200 Subject: [PATCH 3/3] Types on the right (too)! --- packages/flutter_markdown/test/image_test_mocks.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/packages/flutter_markdown/test/image_test_mocks.dart b/packages/flutter_markdown/test/image_test_mocks.dart index 2be1a3f6aa8b..160adc4582aa 100644 --- a/packages/flutter_markdown/test/image_test_mocks.dart +++ b/packages/flutter_markdown/test/image_test_mocks.dart @@ -69,7 +69,7 @@ MockHttpClient createMockImageHttpClient(SecurityContext? _) { } // A list of integers that can be consumed as image data in a stream. -final List _transparentImage = [ +final List _transparentImage = [ // Image bytes. 0x89, 0x50, 0x4E, 0x47, 0x0D, 0x0A, 0x1A, 0x0A, 0x00, 0x00, 0x00, 0x0D, 0x49, 0x48, 0x44, 0x52, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01, 0x08, 0x06,