From cdba6476b0a038c44cb8b1cc06a2ff1ec168850d Mon Sep 17 00:00:00 2001 From: Ankit Mahato Date: Sun, 27 Aug 2023 20:23:41 +0530 Subject: [PATCH] Migrate to Dart 3 --- lib/main.dart | 2 +- lib/providers/collection_providers.dart | 10 +- .../request_pane/request_body.dart | 4 +- .../home_page/editor_pane/editor_pane.dart | 4 +- .../home_page/editor_pane/url_card.dart | 6 +- lib/screens/home_page/home_page.dart | 4 +- lib/services/http_service.dart | 63 ++++----- lib/utils/http_utils.dart | 78 ++++++----- lib/widgets/code_previewer.dart | 19 ++- lib/widgets/response_widgets.dart | 4 +- test/utils/http_utils_test.dart | 128 ++++++++++-------- test/widgets/splitviews_test.dart | 12 +- test/widgets/textfields_test.dart | 8 +- 13 files changed, 178 insertions(+), 164 deletions(-) diff --git a/lib/main.dart b/lib/main.dart index 91d33c8a..3f72d775 100644 --- a/lib/main.dart +++ b/lib/main.dart @@ -13,7 +13,7 @@ void main() async { await setupInitialWindow(); } else { var win = getInitialSize(); - await setupWindow(sz: win.$0, off: win.$1); + await setupWindow(sz: win.$1, off: win.$2); } runApp( ProviderScope( diff --git a/lib/providers/collection_providers.dart b/lib/providers/collection_providers.dart index 9bd24200..841bfeb6 100644 --- a/lib/providers/collection_providers.dart +++ b/lib/providers/collection_providers.dart @@ -132,17 +132,17 @@ class CollectionStateNotifier extends StateNotifier?> { var responseRec = await request(requestModel, defaultUriScheme: defaultUriScheme); late final RequestModel newRequestModel; - if (responseRec.$0 == null) { + if (responseRec.$1 == null) { newRequestModel = requestModel.copyWith( responseStatus: -1, - message: responseRec.$2, + message: responseRec.$3, ); } else { final responseModel = baseResponseModel.fromResponse( - response: responseRec.$0!, - time: responseRec.$1!, + response: responseRec.$1!, + time: responseRec.$2!, ); - int statusCode = responseRec.$0!.statusCode; + int statusCode = responseRec.$1!.statusCode; newRequestModel = requestModel.copyWith( responseStatus: statusCode, message: kResponseCodeReasons[statusCode], diff --git a/lib/screens/home_page/editor_pane/details_card/request_pane/request_body.dart b/lib/screens/home_page/editor_pane/details_card/request_pane/request_body.dart index 24f15e03..cf2821f5 100644 --- a/lib/screens/home_page/editor_pane/details_card/request_pane/request_body.dart +++ b/lib/screens/home_page/editor_pane/details_card/request_pane/request_body.dart @@ -25,11 +25,11 @@ class _EditRequestBodyState extends ConsumerState { margin: kPt5o10, child: Column( children: [ - SizedBox( + const SizedBox( height: kHeaderHeight, child: Row( mainAxisAlignment: MainAxisAlignment.center, - children: const [ + children: [ Text( "Select Content Type:", ), diff --git a/lib/screens/home_page/editor_pane/editor_pane.dart b/lib/screens/home_page/editor_pane/editor_pane.dart index daba1d62..4ff5e17b 100644 --- a/lib/screens/home_page/editor_pane/editor_pane.dart +++ b/lib/screens/home_page/editor_pane/editor_pane.dart @@ -28,8 +28,8 @@ class _RequestEditorPaneState extends ConsumerState { } else { return Padding( padding: kIsMacOS ? kPt24o8 : kP8, - child: Column( - children: const [ + child: const Column( + children: [ EditorPaneRequestURLCard(), kVSpacer10, Expanded( diff --git a/lib/screens/home_page/editor_pane/url_card.dart b/lib/screens/home_page/editor_pane/url_card.dart index 2647695a..e99dac2b 100644 --- a/lib/screens/home_page/editor_pane/url_card.dart +++ b/lib/screens/home_page/editor_pane/url_card.dart @@ -28,13 +28,13 @@ class _EditorPaneRequestURLCardState extends State { ), borderRadius: kBorderRadius12, ), - child: Padding( - padding: const EdgeInsets.symmetric( + child: const Padding( + padding: EdgeInsets.symmetric( vertical: 5, horizontal: 20, ), child: Row( - children: const [ + children: [ DropdownButtonHTTPMethod(), kHSpacer20, Expanded( diff --git a/lib/screens/home_page/home_page.dart b/lib/screens/home_page/home_page.dart index 8b94b598..ae3a7598 100644 --- a/lib/screens/home_page/home_page.dart +++ b/lib/screens/home_page/home_page.dart @@ -13,8 +13,8 @@ class HomePage extends StatefulWidget { class HomePageState extends State { @override Widget build(BuildContext context) { - return Column( - children: const [ + return const Column( + children: [ Expanded( child: DashboardSplitView( sidebarWidget: CollectionPane(), diff --git a/lib/services/http_service.dart b/lib/services/http_service.dart index 2a9ca1ad..1f736d6d 100644 --- a/lib/services/http_service.dart +++ b/lib/services/http_service.dart @@ -7,66 +7,59 @@ import 'package:apidash/models/models.dart'; import 'package:apidash/consts.dart'; Future<(http.Response?, Duration?, String?)> request( - RequestModel requestModel, - {String defaultUriScheme = kDefaultUriScheme} -) async { - (Uri?, String?) uriRec = getValidRequestUri(requestModel.url, - requestModel.requestParams, - defaultUriScheme: defaultUriScheme); - if(uriRec.$0 != null){ - Uri requestUrl = uriRec.$0!; + RequestModel requestModel, { + String defaultUriScheme = kDefaultUriScheme, +}) async { + (Uri?, String?) uriRec = getValidRequestUri( + requestModel.url, + requestModel.requestParams, + defaultUriScheme: defaultUriScheme, + ); + if (uriRec.$1 != null) { + Uri requestUrl = uriRec.$1!; Map headers = rowsToMap(requestModel.requestHeaders) ?? {}; http.Response response; String? body; - try { + try { var requestBody = requestModel.requestBody; - if(kMethodsWithBody.contains(requestModel.method) && requestBody != null){ + if (kMethodsWithBody.contains(requestModel.method) && + requestBody != null) { var contentLength = utf8.encode(requestBody).length; - if (contentLength > 0){ + if (contentLength > 0) { body = requestBody; headers[HttpHeaders.contentLengthHeader] = contentLength.toString(); - headers[HttpHeaders.contentTypeHeader] = kContentTypeMap[requestModel.requestBodyContentType] ?? ""; + headers[HttpHeaders.contentTypeHeader] = + kContentTypeMap[requestModel.requestBodyContentType] ?? ""; } } Stopwatch stopwatch = Stopwatch()..start(); - switch(requestModel.method){ + switch (requestModel.method) { case HTTPVerb.get: - response = await http.get(requestUrl, - headers: headers); + response = await http.get(requestUrl, headers: headers); break; case HTTPVerb.head: - response = await http.head(requestUrl, - headers: headers); + response = await http.head(requestUrl, headers: headers); break; case HTTPVerb.post: - response = await http.post(requestUrl, - headers: headers, - body: body); + response = await http.post(requestUrl, headers: headers, body: body); break; case HTTPVerb.put: - response = await http.put(requestUrl, - headers: headers, - body: body); + response = await http.put(requestUrl, headers: headers, body: body); break; case HTTPVerb.patch: - response = await http.patch(requestUrl, - headers: headers, - body: body); + response = await http.patch(requestUrl, headers: headers, body: body); break; case HTTPVerb.delete: - response = await http.delete(requestUrl, - headers: headers, - body: body); + response = + await http.delete(requestUrl, headers: headers, body: body); break; } - stopwatch.stop(); + stopwatch.stop(); return (response, stopwatch.elapsed, null); - } - catch (e) { + } catch (e) { return (null, null, e.toString()); } - } - else { - return (null, null, uriRec.$1); + } else { + return (null, null, uriRec.$2); } } diff --git a/lib/utils/http_utils.dart b/lib/utils/http_utils.dart index 31437e2f..b0c7d623 100644 --- a/lib/utils/http_utils.dart +++ b/lib/utils/http_utils.dart @@ -44,8 +44,8 @@ MediaType? getMediaTypeFromHeaders(Map? headers) { } (String?, bool) getUriScheme(Uri uri) { - if(uri.hasScheme){ - if(kSupportedUriSchemes.contains(uri.scheme)){ + if (uri.hasScheme) { + if (kSupportedUriSchemes.contains(uri.scheme)) { return (uri.scheme, true); } return (uri.scheme, false); @@ -53,38 +53,34 @@ MediaType? getMediaTypeFromHeaders(Map? headers) { return (null, false); } -(Uri?, String?) getValidRequestUri( - String? url, - List? requestParams, - {String defaultUriScheme = kDefaultUriScheme} -) { +(Uri?, String?) getValidRequestUri(String? url, List? requestParams, + {String defaultUriScheme = kDefaultUriScheme}) { url = url?.trim(); - if(url == null || url == ""){ + if (url == null || url == "") { return (null, "URL is missing!"); } - Uri? uri = Uri.tryParse(url); - if(uri == null){ + Uri? uri = Uri.tryParse(url); + if (uri == null) { return (null, "Check URL (malformed)"); } (String?, bool) urlScheme = getUriScheme(uri); - if(urlScheme.$0 != null){ - if (!urlScheme.$1){ - return (null, "Unsupported URL Scheme (${urlScheme.$0})"); + if (urlScheme.$1 != null) { + if (!urlScheme.$2) { + return (null, "Unsupported URL Scheme (${urlScheme.$1})"); } - } - else { + } else { url = "$defaultUriScheme://$url"; } - uri = Uri.parse(url); - if (uri.hasFragment){ + uri = Uri.parse(url); + if (uri.hasFragment) { uri = uri.removeFragment(); } Map? queryParams = rowsToMap(requestParams); - if(queryParams != null){ - if(uri.hasQuery){ + if (queryParams != null) { + if (uri.hasQuery) { Map urlQueryParams = uri.queryParameters; queryParams = mergeMaps(urlQueryParams, queryParams); } @@ -93,48 +89,58 @@ MediaType? getMediaTypeFromHeaders(Map? headers) { return (uri, null); } -(List, String?) getResponseBodyViewOptions(MediaType? mediaType){ - if(mediaType != null){ +(List, String?) getResponseBodyViewOptions( + MediaType? mediaType) { + if (mediaType != null) { var type = mediaType.type; var subtype = mediaType.subtype; - if(kResponseBodyViewOptions.containsKey(type)){ - if (kResponseBodyViewOptions[type]!.containsKey(subtype)){ - return (kResponseBodyViewOptions[type]![subtype]!, kCodeHighlighterMap[subtype] ?? subtype); + if (kResponseBodyViewOptions.containsKey(type)) { + if (kResponseBodyViewOptions[type]!.containsKey(subtype)) { + return ( + kResponseBodyViewOptions[type]![subtype]!, + kCodeHighlighterMap[subtype] ?? subtype + ); } - if(subtype.contains(kSubTypeJson)){ + if (subtype.contains(kSubTypeJson)) { subtype = kSubTypeJson; } - if(subtype.contains(kSubTypeXml)){ + if (subtype.contains(kSubTypeXml)) { subtype = kSubTypeXml; } - if (kResponseBodyViewOptions[type]!.containsKey(subtype)){ - return (kResponseBodyViewOptions[type]![subtype]!, kCodeHighlighterMap[subtype] ?? subtype); + if (kResponseBodyViewOptions[type]!.containsKey(subtype)) { + return ( + kResponseBodyViewOptions[type]![subtype]!, + kCodeHighlighterMap[subtype] ?? subtype + ); } - return (kResponseBodyViewOptions[type]![kSubTypeDefaultViewOptions]!, subtype); + return ( + kResponseBodyViewOptions[type]![kSubTypeDefaultViewOptions]!, + subtype + ); } } return (kNoBodyViewOptions, null); } -String? formatBody(String? body, MediaType? mediaType){ - if(mediaType != null && body != null){ +String? formatBody(String? body, MediaType? mediaType) { + if (mediaType != null && body != null) { var subtype = mediaType.subtype; try { - if(subtype.contains(kSubTypeJson)){ + if (subtype.contains(kSubTypeJson)) { final tmp = jsonDecode(body); String result = kEncoder.convert(tmp); return result; } - if(subtype.contains(kSubTypeXml)){ + if (subtype.contains(kSubTypeXml)) { final document = XmlDocument.parse(body); String result = document.toXmlString(pretty: true, indent: ' '); return result; } - if(subtype == kSubTypeHtml){ + if (subtype == kSubTypeHtml) { var len = body.length; var lines = kSplitter.convert(body); var numOfLines = lines.length; - if(numOfLines !=0 && len/numOfLines <= kCodeCharsPerLineLimit){ + if (numOfLines != 0 && len / numOfLines <= kCodeCharsPerLineLimit) { return body; } } @@ -143,4 +149,4 @@ String? formatBody(String? body, MediaType? mediaType){ } } return null; -} \ No newline at end of file +} diff --git a/lib/widgets/code_previewer.dart b/lib/widgets/code_previewer.dart index a073fb21..b4e7223b 100644 --- a/lib/widgets/code_previewer.dart +++ b/lib/widgets/code_previewer.dart @@ -6,7 +6,7 @@ import 'error_message.dart'; (String, bool) sanitize(String input) { bool limitedLines = false; int tabSize = 4; - var lines = kSplitter.convert(input); + var lines = kSplitter.convert(input); if (lines.length > kCodePreviewLinesLimit) { lines = lines.sublist(0, kCodePreviewLinesLimit); limitedLines = true; @@ -67,7 +67,12 @@ class _CodePreviewerState extends State { textStyle = textStyle.merge(widget.textStyle); } processed = sanitize(widget.code); - spans = asyncGenerateSpans(processed.$0, widget.language, widget.theme, processed.$1); + spans = asyncGenerateSpans( + processed.$1, + widget.language, + widget.theme, + processed.$2, + ); } @override @@ -131,12 +136,14 @@ class _CodePreviewerState extends State { } } -Future> asyncGenerateSpans( - String code, String? language, Map theme, bool limitedLines) async { +Future> asyncGenerateSpans(String code, String? language, + Map theme, bool limitedLines) async { var parsed = highlight.parse(code, language: language); var spans = convert(parsed.nodes!, theme); - if(limitedLines) { - spans.add(const TextSpan(text: "\n... more.\nPreview ends here ($kCodePreviewLinesLimit lines).\nYou can check Raw for full result.")); + if (limitedLines) { + spans.add(const TextSpan( + text: + "\n... more.\nPreview ends here ($kCodePreviewLinesLimit lines).\nYou can check Raw for full result.")); } return spans; } diff --git a/lib/widgets/response_widgets.dart b/lib/widgets/response_widgets.dart index ca58dd8d..5bcd9c7d 100644 --- a/lib/widgets/response_widgets.dart +++ b/lib/widgets/response_widgets.dart @@ -339,8 +339,8 @@ class _ResponseBodyState extends State { } var responseBodyView = getResponseBodyViewOptions(mediaType); - var options = responseBodyView.$0; - var highlightLanguage = responseBodyView.$1; + var options = responseBodyView.$1; + var highlightLanguage = responseBodyView.$2; if (formattedBody == null) { options = [...options]; diff --git a/test/utils/http_utils_test.dart b/test/utils/http_utils_test.dart index 80d63103..afbee444 100644 --- a/test/utils/http_utils_test.dart +++ b/test/utils/http_utils_test.dart @@ -156,22 +156,20 @@ void main() { path: 'guides/libraries/library-tour', fragment: 'numbers'); String uriScheme1Expected = 'https'; - expect(getUriScheme(uri1), (uriScheme1Expected,true)); + expect(getUriScheme(uri1), (uriScheme1Expected, true)); }); test('Testing getUriScheme for mailto scheme value', () { Uri uri2 = Uri(scheme: 'mailto'); String uriScheme2Expected = 'mailto'; - expect(getUriScheme(uri2), (uriScheme2Expected,false)); + expect(getUriScheme(uri2), (uriScheme2Expected, false)); }); test('Testing getUriScheme for empty scheme value', () { - Uri uri3 = Uri( - scheme: ''); - expect(getUriScheme(uri3), (null,false)); + Uri uri3 = Uri(scheme: ''); + expect(getUriScheme(uri3), (null, false)); }); test('Testing getUriScheme for null scheme value', () { - Uri uri4 = Uri( - scheme: null); - expect(getUriScheme(uri4), (null,false)); + Uri uri4 = Uri(scheme: null); + expect(getUriScheme(uri4), (null, false)); }); }); @@ -183,7 +181,7 @@ void main() { scheme: 'https', host: 'api.foss42.com', path: 'country/data', - queryParameters: {'code':'US'}); + queryParameters: {'code': 'US'}); expect(getValidRequestUri(url1, [kvRow1]), (uri1Expected, null)); }); test('Testing getValidRequestUri for null url value', () { @@ -201,29 +199,31 @@ void main() { scheme: 'https', host: 'api.foss42.com', path: 'country/data', - queryParameters: {'code':'US'}); + queryParameters: {'code': 'US'}); expect(getValidRequestUri(url4, [kvRow4]), (uri4Expected, null)); }); test('Testing getValidRequestUri when url has fragment', () { String url5 = "https://dart.dev/guides/libraries/library-tour#numbers"; Uri uri5Expected = Uri( - scheme: 'https', - host: 'dart.dev', - path: '/guides/libraries/library-tour'); + scheme: 'https', + host: 'dart.dev', + path: '/guides/libraries/library-tour'); expect(getValidRequestUri(url5, null), (uri5Expected, null)); }); test('Testing getValidRequestUri when uri scheme is not supported', () { String url5 = "mailto:someone@example.com"; - expect(getValidRequestUri(url5, null), (null, "Unsupported URL Scheme (mailto)")); + expect(getValidRequestUri(url5, null), + (null, "Unsupported URL Scheme (mailto)")); }); - test('Testing getValidRequestUri when query params in both url and kvrow', () { + test('Testing getValidRequestUri when query params in both url and kvrow', + () { String url6 = "api.foss42.com/country/data?code=IND"; KVRow kvRow6 = const KVRow("code", "US"); Uri uri6Expected = Uri( scheme: 'https', host: 'api.foss42.com', path: 'country/data', - queryParameters: {'code':'US'}); + queryParameters: {'code': 'US'}); expect(getValidRequestUri(url6, [kvRow6]), (uri6Expected, null)); }); test('Testing getValidRequestUri when kvrow is null', () { @@ -232,7 +232,7 @@ void main() { scheme: 'https', host: 'api.foss42.com', path: 'country/data', - queryParameters: {'code':'US'}); + queryParameters: {'code': 'US'}); expect(getValidRequestUri(url7, null), (uri7Expected, null)); }); }); @@ -241,72 +241,78 @@ void main() { test('Testing getResponseBodyViewOptions for application/json', () { MediaType mediaType1 = MediaType("application", "json"); var result1 = getResponseBodyViewOptions(mediaType1); - expect(result1.$0,kCodeRawBodyViewOptions); - expect(result1.$1, "json"); + expect(result1.$1, kCodeRawBodyViewOptions); + expect(result1.$2, "json"); }); test('Testing getResponseBodyViewOptions for application/xml', () { MediaType mediaType2 = MediaType("application", "xml"); var result2 = getResponseBodyViewOptions(mediaType2); - expect(result2.$0, kCodeRawBodyViewOptions); - expect(result2.$1,"xml"); + expect(result2.$1, kCodeRawBodyViewOptions); + expect(result2.$2, "xml"); }); - test('Testing getResponseBodyViewOptions for message/news a format currently not supported', () { + test( + 'Testing getResponseBodyViewOptions for message/news a format currently not supported', + () { MediaType mediaType3 = MediaType("message", "news"); var result3 = getResponseBodyViewOptions(mediaType3); - expect(result3.$0,kNoBodyViewOptions); - expect(result3.$1,null); + expect(result3.$1, kNoBodyViewOptions); + expect(result3.$2, null); }); - test('Testing getResponseBodyViewOptions for application/calendar+json', () { + test('Testing getResponseBodyViewOptions for application/calendar+json', + () { MediaType mediaType4 = MediaType("application", "calendar+json"); var result4 = getResponseBodyViewOptions(mediaType4); - expect(result4.$0,kCodeRawBodyViewOptions); - expect(result4.$1, "json"); + expect(result4.$1, kCodeRawBodyViewOptions); + expect(result4.$2, "json"); }); test('Testing getResponseBodyViewOptions for image/svg+xml', () { MediaType mediaType5 = MediaType("image", "svg+xml"); var result5 = getResponseBodyViewOptions(mediaType5); - expect(result5.$0,kCodeRawBodyViewOptions); - expect(result5.$1, "xml"); + expect(result5.$1, kCodeRawBodyViewOptions); + expect(result5.$2, "xml"); }); test('Testing getResponseBodyViewOptions for application/xhtml+xml', () { MediaType mediaType6 = MediaType("application", "xhtml+xml"); var result6 = getResponseBodyViewOptions(mediaType6); - expect(result6.$0,kCodeRawBodyViewOptions); - expect(result6.$1, "xml"); + expect(result6.$1, kCodeRawBodyViewOptions); + expect(result6.$2, "xml"); }); - test('Testing getResponseBodyViewOptions for application/xml-external-parsed-entity', () { - MediaType mediaType7 = MediaType("application", "xml-external-parsed-entity"); + test( + 'Testing getResponseBodyViewOptions for application/xml-external-parsed-entity', + () { + MediaType mediaType7 = + MediaType("application", "xml-external-parsed-entity"); var result7 = getResponseBodyViewOptions(mediaType7); - expect(result7.$0,kCodeRawBodyViewOptions); - expect(result7.$1, "xml"); + expect(result7.$1, kCodeRawBodyViewOptions); + expect(result7.$2, "xml"); }); test('Testing getResponseBodyViewOptions for text/html', () { MediaType mediaType8 = MediaType("text", "html"); var result8 = getResponseBodyViewOptions(mediaType8); - expect(result8.$0,kCodeRawBodyViewOptions); - expect(result8.$1, "xml"); + expect(result8.$1, kCodeRawBodyViewOptions); + expect(result8.$2, "xml"); }); test('Testing getResponseBodyViewOptions for application/pdf', () { MediaType mediaType9 = MediaType("application", "pdf"); var result9 = getResponseBodyViewOptions(mediaType9); - expect(result9.$0,kNoBodyViewOptions); - expect(result9.$1, "pdf"); + expect(result9.$1, kNoBodyViewOptions); + expect(result9.$2, "pdf"); }); - test('Testing getResponseBodyViewOptions for text/calendar', () { + test('Testing getResponseBodyViewOptions for text/calendar', () { MediaType mediaType10 = MediaType("text", "calendar"); var result10 = getResponseBodyViewOptions(mediaType10); - expect(result10.$0,kRawBodyViewOptions); - expect(result10.$1, "calendar"); + expect(result10.$1, kRawBodyViewOptions); + expect(result10.$2, "calendar"); }); }); group("Testing formatBody", () { test('Testing formatBody for null values', () { - expect(formatBody(null, null),null); + expect(formatBody(null, null), null); }); test('Testing formatBody for null body values', () { MediaType mediaType1 = MediaType("application", "xml"); - expect(formatBody(null, mediaType1),null); + expect(formatBody(null, mediaType1), null); }); test('Testing formatBody for null MediaType values', () { String body1 = ''' @@ -314,7 +320,7 @@ void main() { "text":"The Chosen One"; } '''; - expect(formatBody(body1, null),null); + expect(formatBody(body1, null), null); }); test('Testing formatBody for json subtype values', () { String body2 = '''{"data":{"area":9831510.0,"population":331893745}}'''; @@ -325,7 +331,7 @@ void main() { "population": 331893745 } }'''; - expect(formatBody(body2, mediaType2),result2Expected); + expect(formatBody(body2, mediaType2), result2Expected); }); test('Testing formatBody for xml subtype values', () { String body3 = ''' @@ -347,28 +353,30 @@ void main() { 650 '''; - expect(formatBody(body3, mediaType3),result3Expected); + expect(formatBody(body3, mediaType3), result3Expected); }); group("Testing formatBody for html", () { MediaType mediaTypeHtml = MediaType("text", "html"); test('Testing formatBody for html subtype values', () { - String body4 = ''' + String body4 = '''

My First Heading

My first paragraph.

-'''; - expect(formatBody(body4, mediaTypeHtml),body4); +'''; + expect(formatBody(body4, mediaTypeHtml), body4); + }); + + test('Testing formatBody for html subtype values with random values', () { + String body5 = '''${getRandomStringLines(100, 10000)}'''; + expect(formatBody(body5, mediaTypeHtml), null); + }); + test( + 'Testing formatBody for html subtype values with random values within limit', + () { + String body6 = '''${getRandomStringLines(100, 190)}'''; + expect(formatBody(body6, mediaTypeHtml), body6); + }); }); - - test('Testing formatBody for html subtype values with random values', () { - String body5 = '''${getRandomStringLines(100, 10000)}'''; - expect(formatBody(body5, mediaTypeHtml),null); - }); - test('Testing formatBody for html subtype values with random values within limit', () { - String body6 = '''${getRandomStringLines(100, 190)}'''; - expect(formatBody(body6, mediaTypeHtml),body6); - }); - }); }); } diff --git a/test/widgets/splitviews_test.dart b/test/widgets/splitviews_test.dart index 108947cb..3e9d8d59 100644 --- a/test/widgets/splitviews_test.dart +++ b/test/widgets/splitviews_test.dart @@ -6,12 +6,12 @@ import 'package:multi_split_view/multi_split_view.dart'; void main() { testWidgets('Testing for Dashboard Splitview', (tester) async { await tester.pumpWidget( - MaterialApp( + const MaterialApp( title: 'Dashboard Splitview', home: Scaffold( body: DashboardSplitView( - sidebarWidget: Column(children: const [Text("Hello")]), - mainWidget: Column(children: const [Text("World")]), + sidebarWidget: Column(children: [Text("Hello")]), + mainWidget: Column(children: [Text("World")]), ), ), ), @@ -23,12 +23,12 @@ void main() { }); testWidgets('Testing for Equal SplitView', (tester) async { await tester.pumpWidget( - MaterialApp( + const MaterialApp( title: 'Equal SplitView', home: Scaffold( body: EqualSplitView( - leftWidget: Column(children: const [Text("Hello equal")]), - rightWidget: Column(children: const [Text("World equal")]), + leftWidget: Column(children: [Text("Hello equal")]), + rightWidget: Column(children: [Text("World equal")]), ), ), ), diff --git a/test/widgets/textfields_test.dart b/test/widgets/textfields_test.dart index 632b84e0..b50bf4bd 100644 --- a/test/widgets/textfields_test.dart +++ b/test/widgets/textfields_test.dart @@ -10,8 +10,8 @@ void main() { MaterialApp( title: 'URL Field', theme: kThemeDataDark, - home: Scaffold( - body: Column(children: const [URLField(activeId: '2')]), + home: const Scaffold( + body: Column(children: [URLField(activeId: '2')]), ), ), ); @@ -30,9 +30,9 @@ void main() { MaterialApp( title: 'CellField', theme: kThemeDataLight, - home: Scaffold( + home: const Scaffold( body: Column( - children: const [ + children: [ CellField( keyId: "4", hintText: "Passing some hint text",