From 2c515b03cb7b0f88c94ff8fe0721d8249147b052 Mon Sep 17 00:00:00 2001 From: Chinmay Chaudhari Date: Sat, 24 Feb 2024 08:52:05 +0530 Subject: [PATCH 01/24] Changed consts.dart --- lib/consts.dart | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/consts.dart b/lib/consts.dart index f8f9f97c..84620491 100644 --- a/lib/consts.dart +++ b/lib/consts.dart @@ -375,6 +375,7 @@ const Map>> kSubTypeDefaultViewOptions: kRawBodyViewOptions, kSubTypeCss: kCodeRawBodyViewOptions, kSubTypeHtml: kCodeRawBodyViewOptions, + kSubTypeCsv: kPreviewCodeRawBodyViewOptions, kSubTypeJavascript: kCodeRawBodyViewOptions, kSubTypeMarkdown: kCodeRawBodyViewOptions, kSubTypeTextXml: kCodeRawBodyViewOptions, @@ -492,6 +493,10 @@ const kAudioError = const kRaiseIssue = "\nPlease raise an issue in API Dash GitHub repo so that we can resolve it."; +const kCsvError = + "There seems to be an issue rendering this CSV image. Please raise an issue in API Dash GitHub repo so that we can resolve it."; + + const kHintTextUrlCard = "Enter API endpoint like api.foss42.com/country/codes"; const kLabelPlusNew = "+ New"; const kLabelSend = "Send"; From 4a519cfa0ab8c4e389af160a86d184f0a75d96ac Mon Sep 17 00:00:00 2001 From: Chinmay Chaudhari Date: Sat, 24 Feb 2024 09:07:40 +0530 Subject: [PATCH 02/24] csv added --- lib/widgets/csv_previewer.dart | 49 ++++++++++++++++++++++++++++++++ lib/widgets/previewer.dart | 9 ++++++ pubspec.yaml | 1 + test/widgets/previewer_test.dart | 22 ++++++++++++++ 4 files changed, 81 insertions(+) create mode 100644 lib/widgets/csv_previewer.dart diff --git a/lib/widgets/csv_previewer.dart b/lib/widgets/csv_previewer.dart new file mode 100644 index 00000000..cdfc45b0 --- /dev/null +++ b/lib/widgets/csv_previewer.dart @@ -0,0 +1,49 @@ +import 'package:flutter/material.dart'; +import 'package:csv/csv.dart'; +import 'package:apidash/consts.dart'; +import 'package:apidash/widgets/widgets.dart'; + +class CsvPreviewer extends StatelessWidget { + const CsvPreviewer({Key? key, required this.body}) : super(key: key); + + final String body; + + @override + Widget build(BuildContext context) { + try { + final List> csvData = const CsvToListConverter().convert(body, eol: '\n'); + return SingleChildScrollView( + scrollDirection: Axis.horizontal, + child: DataTable( + columns: csvData[0] + .map( + (item) => DataColumn( + label: Text( + item.toString(), + ), + ), + ) + .toList(), + rows: csvData + .skip(1) + .map( + (csvrow) => DataRow( + cells: csvrow + .map( + (csvItem) => DataCell( + Text( + csvItem.toString(), + ), + ), + ) + .toList(), + ), + ) + .toList(), + ), + ); + } catch (e) { + return const ErrorMessage(message: kCsvError); + } + } +} diff --git a/lib/widgets/previewer.dart b/lib/widgets/previewer.dart index 9841ac5b..6a6eb828 100644 --- a/lib/widgets/previewer.dart +++ b/lib/widgets/previewer.dart @@ -1,4 +1,5 @@ import 'dart:convert'; +import 'package:apidash/widgets/csv_previewer.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:printing/printing.dart'; @@ -81,6 +82,13 @@ class _PreviewerState extends State { }, ); } + if (widget.type == kTypeText && widget.subtype == kSubTypeCsv) { + try { + return CsvPreviewer(body: widget.body); + } catch (e) { + return const ErrorMessage(message: kCsvError); + } + } if (widget.type == kTypeVideo) { // TODO: Video Player } @@ -89,4 +97,5 @@ class _PreviewerState extends State { : "$kMimeTypeRaiseIssueStart${widget.type}/${widget.subtype}$kMimeTypeRaiseIssue"; return ErrorMessage(message: message); } + } diff --git a/pubspec.yaml b/pubspec.yaml index 4196d007..a95361b4 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -54,6 +54,7 @@ dependencies: code_builder: ^4.9.0 dart_style: ^2.3.4 json_text_field: ^1.1.0 + csv: ^5.1.1 dev_dependencies: flutter_test: diff --git a/test/widgets/previewer_test.dart b/test/widgets/previewer_test.dart index 0d2f68cd..c26793bb 100644 --- a/test/widgets/previewer_test.dart +++ b/test/widgets/previewer_test.dart @@ -231,4 +231,26 @@ void main() { await tester.pumpAndSettle(); expect(find.text(kSvgError), findsOneWidget); }); + + testWidgets('Testing when type/subtype is text/csv', (tester) async { + String csvDataString = + 'Id,Name,Age\n1,John Doe,40\n2,Dbestech,41\n3,Voldermort,71\n4,Joe Biden,80\n5,Ryo Hanamura,35'; + + await tester.pumpWidget( + MaterialApp( + home: Scaffold( + body: Previewer( + type: kTypeText, + subtype: kSubTypeCsv, + bytes: Uint8List.fromList([]), + body: csvDataString, + ), + ), + ), + ); + + expect(find.byType(DataTable), findsOneWidget); + expect(find.text('John Doe'), findsOneWidget); + expect(find.text('41'), findsOneWidget); + }); } From 714a33ca370a627010656e92611d76a5ea3504c4 Mon Sep 17 00:00:00 2001 From: Chinmay Chaudhari Date: Sat, 24 Feb 2024 09:47:47 +0530 Subject: [PATCH 03/24] fixed typo --- lib/consts.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/consts.dart b/lib/consts.dart index 84620491..8d04c2eb 100644 --- a/lib/consts.dart +++ b/lib/consts.dart @@ -494,7 +494,7 @@ const kRaiseIssue = "\nPlease raise an issue in API Dash GitHub repo so that we can resolve it."; const kCsvError = - "There seems to be an issue rendering this CSV image. Please raise an issue in API Dash GitHub repo so that we can resolve it."; + "There seems to be an issue rendering this CSV. Please raise an issue in API Dash GitHub repo so that we can resolve it."; const kHintTextUrlCard = "Enter API endpoint like api.foss42.com/country/codes"; From 2702760cd0863e625b1c39a3b3bfb244ed558aec Mon Sep 17 00:00:00 2001 From: Delwin Mathew <84124091+opxdelwin@users.noreply.github.com> Date: Sat, 24 Feb 2024 22:20:39 +0530 Subject: [PATCH 04/24] add analysis workflow --- .github/workflows/analyze.yml | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 .github/workflows/analyze.yml diff --git a/.github/workflows/analyze.yml b/.github/workflows/analyze.yml new file mode 100644 index 00000000..0d5b1fb6 --- /dev/null +++ b/.github/workflows/analyze.yml @@ -0,0 +1,22 @@ +name: "Code Analysis" +on: [ push ] + + +jobs: + Flutter-Analyze: + runs-on: ubuntu-latest + steps: + - run: pwd + - name: Checkout Code + uses: actions/checkout@v3 + + - name: Get Flutter Env + uses: subosito/flutter-action@v2 + with: + channel: 'stable' + - run: flutter --version + + - name: Code Analysis + run: | + flutter pub get + flutter analyze From d22608ac0101c9f21f72f84cdf1e5b39f4d89030 Mon Sep 17 00:00:00 2001 From: Tanish2002 Date: Mon, 26 Feb 2024 01:36:19 +0530 Subject: [PATCH 05/24] feat: update flutter_typeahead --- lib/widgets/headerfield.dart | 40 +++++++++---------- pubspec.lock | 76 +++++++++++++++++++++++++++++------- pubspec.yaml | 2 +- 3 files changed, 82 insertions(+), 36 deletions(-) diff --git a/lib/widgets/headerfield.dart b/lib/widgets/headerfield.dart index 9c678ee3..52dd8ec5 100644 --- a/lib/widgets/headerfield.dart +++ b/lib/widgets/headerfield.dart @@ -1,6 +1,6 @@ +import 'package:apidash/consts.dart'; import 'package:apidash/utils/header_utils.dart'; import 'package:flutter/material.dart'; -import 'package:apidash/consts.dart'; import 'package:flutter_typeahead/flutter_typeahead.dart'; class HeaderField extends StatefulWidget { @@ -41,6 +41,7 @@ class _HeaderFieldState extends State { @override void didUpdateWidget(HeaderField oldWidget) { + super.didUpdateWidget(oldWidget); if (oldWidget.initialValue != widget.initialValue) { controller.text = widget.initialValue ?? ""; controller.selection = @@ -53,9 +54,9 @@ class _HeaderFieldState extends State { var colorScheme = widget.colorScheme ?? Theme.of(context).colorScheme; return TypeAheadField( key: Key(widget.keyId), - hideOnEmpty: true, - minCharsForSuggestions: 1, - onSuggestionSelected: (value) { + hideOnEmpty: false, + controller: controller, + onSelected: (value) { setState(() { controller.text = value; }); @@ -68,19 +69,16 @@ class _HeaderFieldState extends State { ); }, suggestionsCallback: headerSuggestionCallback, - suggestionsBoxDecoration: suggestionBoxDecorations(context), - textFieldConfiguration: TextFieldConfiguration( + decorationBuilder: suggestionBoxDecorations, + constraints: const BoxConstraints(maxHeight: 400), + builder: (context, controller, focusNode) => TextField( onChanged: widget.onChanged, controller: controller, - style: kCodeStyle.copyWith( - color: colorScheme.onSurface, - ), + focusNode: focusNode, + style: kCodeStyle.copyWith(color: colorScheme.onSurface), decoration: InputDecoration( hintStyle: kCodeStyle.copyWith( - color: colorScheme.outline.withOpacity( - kHintOpacity, - ), - ), + color: colorScheme.outline.withOpacity(kHintOpacity)), hintText: widget.hintText, focusedBorder: UnderlineInputBorder( borderSide: BorderSide( @@ -99,22 +97,22 @@ class _HeaderFieldState extends State { ); } - SuggestionsBoxDecoration suggestionBoxDecorations(BuildContext context) { - return SuggestionsBoxDecoration( + Material suggestionBoxDecorations(BuildContext context, Widget child) { + return Material( elevation: 4, - constraints: const BoxConstraints(maxHeight: 400), shape: RoundedRectangleBorder( - side: BorderSide( - color: Theme.of(context).dividerColor, - width: 1.2, - ), + side: BorderSide(color: Theme.of(context).dividerColor, width: 1.2), borderRadius: const BorderRadius.vertical(bottom: Radius.circular(8)), ), clipBehavior: Clip.hardEdge, + child: child, ); } - Future> headerSuggestionCallback(String pattern) async { + Future?> headerSuggestionCallback(String pattern) async { + if (pattern.isEmpty) { + return null; + } return getHeaderSuggestions(pattern); } } diff --git a/pubspec.lock b/pubspec.lock index 2f3f7f55..70dda7d5 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -306,10 +306,10 @@ packages: dependency: transitive description: name: flutter_keyboard_visibility - sha256: "4983655c26ab5b959252ee204c2fffa4afeb4413cd030455194ec0caa3b8e7cb" + sha256: "98664be7be0e3ffca00de50f7f6a287ab62c763fc8c762e0a21584584a3ff4f8" url: "https://pub.dev" source: hosted - version: "5.4.1" + version: "6.0.0" flutter_keyboard_visibility_linux: dependency: transitive description: @@ -407,10 +407,10 @@ packages: dependency: "direct main" description: name: flutter_typeahead - sha256: b9942bd5b7611a6ec3f0730c477146cffa4cd4b051077983ba67ddfc9e7ee818 + sha256: d64712c65db240b1057559b952398ebb6e498077baeebf9b0731dade62438a6d url: "https://pub.dev" source: hosted - version: "4.8.0" + version: "5.2.0" flutter_web_plugins: dependency: transitive description: flutter @@ -625,6 +625,30 @@ packages: url: "https://pub.dev" source: hosted version: "0.2.0" + leak_tracker: + dependency: transitive + description: + name: leak_tracker + sha256: "78eb209deea09858f5269f5a5b02be4049535f568c07b275096836f01ea323fa" + url: "https://pub.dev" + source: hosted + version: "10.0.0" + leak_tracker_flutter_testing: + dependency: transitive + description: + name: leak_tracker_flutter_testing + sha256: b46c5e37c19120a8a01918cfaf293547f47269f7cb4b0058f21531c2465d6ef0 + url: "https://pub.dev" + source: hosted + version: "2.0.1" + leak_tracker_testing: + dependency: transitive + description: + name: leak_tracker_testing + sha256: a597f72a664dbd293f3bfc51f9ba69816f84dcd403cdac7066cb3f6003f3ab47 + url: "https://pub.dev" + source: hosted + version: "2.0.1" lints: dependency: transitive description: @@ -661,26 +685,26 @@ packages: dependency: transitive description: name: matcher - sha256: "1803e76e6653768d64ed8ff2e1e67bea3ad4b923eb5c56a295c3e634bad5960e" + sha256: d2323aa2060500f906aa31a895b4030b6da3ebdcc5619d14ce1aada65cd161cb url: "https://pub.dev" source: hosted - version: "0.12.16" + version: "0.12.16+1" material_color_utilities: dependency: transitive description: name: material_color_utilities - sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41" + sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a" url: "https://pub.dev" source: hosted - version: "0.5.0" + version: "0.8.0" meta: dependency: transitive description: name: meta - sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e + sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04 url: "https://pub.dev" source: hosted - version: "1.10.0" + version: "1.11.0" mime: dependency: transitive description: @@ -757,10 +781,10 @@ packages: dependency: "direct main" description: name: path - sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917" + sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af" url: "https://pub.dev" source: hosted - version: "1.8.3" + version: "1.9.0" path_parsing: dependency: transitive description: @@ -853,10 +877,34 @@ packages: dependency: transitive description: name: pointer_interceptor - sha256: adf7a637f97c077041d36801b43be08559fd4322d2127b3f20bb7be1b9eebc22 + sha256: bd18321519718678d5fa98ad3a3359cbc7a31f018554eab80b73d08a7f0c165a url: "https://pub.dev" source: hosted - version: "0.9.3+7" + version: "0.10.1" + pointer_interceptor_ios: + dependency: transitive + description: + name: pointer_interceptor_ios + sha256: "2e73c39452830adc4695757130676a39412a3b7f3c34e3f752791b5384770877" + url: "https://pub.dev" + source: hosted + version: "0.10.0+2" + pointer_interceptor_platform_interface: + dependency: transitive + description: + name: pointer_interceptor_platform_interface + sha256: "0597b0560e14354baeb23f8375cd612e8bd4841bf8306ecb71fcd0bb78552506" + url: "https://pub.dev" + source: hosted + version: "0.10.0+1" + pointer_interceptor_web: + dependency: transitive + description: + name: pointer_interceptor_web + sha256: "9386e064097fd16419e935c23f08f35b58e6aaec155dd39bd6a003b88f9c14b4" + url: "https://pub.dev" + source: hosted + version: "0.10.1+2" pointycastle: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index 4196d007..075d9695 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -41,7 +41,7 @@ dependencies: json_annotation: ^4.8.1 printing: ^5.11.1 package_info_plus: ^4.1.0 - flutter_typeahead: ^4.8.0 + flutter_typeahead: ^5.2.0 provider: ^6.0.5 json_data_explorer: git: From 11515a988b6b2daadb577f28f2780e41a49620bb Mon Sep 17 00:00:00 2001 From: Tanish2002 Date: Mon, 26 Feb 2024 03:51:44 +0530 Subject: [PATCH 06/24] fix: colors not changing in headers suggestion list --- lib/widgets/headerfield.dart | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/lib/widgets/headerfield.dart b/lib/widgets/headerfield.dart index 52dd8ec5..dbe45886 100644 --- a/lib/widgets/headerfield.dart +++ b/lib/widgets/headerfield.dart @@ -54,7 +54,7 @@ class _HeaderFieldState extends State { var colorScheme = widget.colorScheme ?? Theme.of(context).colorScheme; return TypeAheadField( key: Key(widget.keyId), - hideOnEmpty: false, + hideOnEmpty: true, controller: controller, onSelected: (value) { setState(() { @@ -65,11 +65,15 @@ class _HeaderFieldState extends State { itemBuilder: (context, String suggestion) { return ListTile( dense: true, - title: Text(suggestion), + title: Text( + suggestion, + style: TextStyle(color: colorScheme.inverseSurface), + ), ); }, suggestionsCallback: headerSuggestionCallback, - decorationBuilder: suggestionBoxDecorations, + decorationBuilder: (context, child) => + suggestionBoxDecorations(context, child, colorScheme), constraints: const BoxConstraints(maxHeight: 400), builder: (context, controller, focusNode) => TextField( onChanged: widget.onChanged, @@ -97,9 +101,11 @@ class _HeaderFieldState extends State { ); } - Material suggestionBoxDecorations(BuildContext context, Widget child) { + Material suggestionBoxDecorations( + BuildContext context, Widget child, ColorScheme colorScheme) { return Material( elevation: 4, + color: colorScheme.surface, shape: RoundedRectangleBorder( side: BorderSide(color: Theme.of(context).dividerColor, width: 1.2), borderRadius: const BorderRadius.vertical(bottom: Radius.circular(8)), From 79b9c312dee740ca2a3efa5e89ee8dc4531a9649 Mon Sep 17 00:00:00 2001 From: Tanish2002 Date: Mon, 26 Feb 2024 06:46:50 +0530 Subject: [PATCH 07/24] fix(headers list): scrollbar color not changing in darkmode --- lib/widgets/headerfield.dart | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/lib/widgets/headerfield.dart b/lib/widgets/headerfield.dart index dbe45886..be1a7171 100644 --- a/lib/widgets/headerfield.dart +++ b/lib/widgets/headerfield.dart @@ -75,6 +75,25 @@ class _HeaderFieldState extends State { decorationBuilder: (context, child) => suggestionBoxDecorations(context, child, colorScheme), constraints: const BoxConstraints(maxHeight: 400), + listBuilder: (context, children) => Theme( + data: ThemeData( + scrollbarTheme: ScrollbarThemeData( + thumbColor: MaterialStateProperty.all(colorScheme.inverseSurface), + trackColor: MaterialStateProperty.all( + colorScheme.inverseSurface.withOpacity(0.3)), + ), + ), + child: ListView.builder( + shrinkWrap: true, + itemCount: children.length, + itemBuilder: (context, index) { + return Container( + margin: const EdgeInsets.all(8), + child: children[index], + ); + }, + ), + ), builder: (context, controller, focusNode) => TextField( onChanged: widget.onChanged, controller: controller, From b802ca7f84537e719b653babba71bfca0ceeb51e Mon Sep 17 00:00:00 2001 From: Tanish2002 Date: Mon, 26 Feb 2024 09:01:48 +0530 Subject: [PATCH 08/24] fix(headers list): some colorscheme fixes --- lib/widgets/headerfield.dart | 44 ++++++++++-------------------------- 1 file changed, 12 insertions(+), 32 deletions(-) diff --git a/lib/widgets/headerfield.dart b/lib/widgets/headerfield.dart index be1a7171..5bce6c8f 100644 --- a/lib/widgets/headerfield.dart +++ b/lib/widgets/headerfield.dart @@ -65,35 +65,13 @@ class _HeaderFieldState extends State { itemBuilder: (context, String suggestion) { return ListTile( dense: true, - title: Text( - suggestion, - style: TextStyle(color: colorScheme.inverseSurface), - ), + title: Text(suggestion), ); }, suggestionsCallback: headerSuggestionCallback, decorationBuilder: (context, child) => suggestionBoxDecorations(context, child, colorScheme), constraints: const BoxConstraints(maxHeight: 400), - listBuilder: (context, children) => Theme( - data: ThemeData( - scrollbarTheme: ScrollbarThemeData( - thumbColor: MaterialStateProperty.all(colorScheme.inverseSurface), - trackColor: MaterialStateProperty.all( - colorScheme.inverseSurface.withOpacity(0.3)), - ), - ), - child: ListView.builder( - shrinkWrap: true, - itemCount: children.length, - itemBuilder: (context, index) { - return Container( - margin: const EdgeInsets.all(8), - child: children[index], - ); - }, - ), - ), builder: (context, controller, focusNode) => TextField( onChanged: widget.onChanged, controller: controller, @@ -120,17 +98,19 @@ class _HeaderFieldState extends State { ); } - Material suggestionBoxDecorations( + Theme suggestionBoxDecorations( BuildContext context, Widget child, ColorScheme colorScheme) { - return Material( - elevation: 4, - color: colorScheme.surface, - shape: RoundedRectangleBorder( - side: BorderSide(color: Theme.of(context).dividerColor, width: 1.2), - borderRadius: const BorderRadius.vertical(bottom: Radius.circular(8)), + return Theme( + data: ThemeData(colorScheme: colorScheme), + child: Material( + elevation: 4, + shape: RoundedRectangleBorder( + side: BorderSide(color: Theme.of(context).dividerColor, width: 1.2), + borderRadius: const BorderRadius.vertical(bottom: Radius.circular(8)), + ), + clipBehavior: Clip.hardEdge, + child: child, ), - clipBehavior: Clip.hardEdge, - child: child, ); } From dcc72f1cccd2e209764675abee81547902539b13 Mon Sep 17 00:00:00 2001 From: Ashita Prasad Date: Tue, 27 Feb 2024 10:40:09 +0530 Subject: [PATCH 09/24] Update analysis_options.yaml --- analysis_options.yaml | 2 -- 1 file changed, 2 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index 1d5eafa4..bde061bb 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -3,8 +3,6 @@ include: package:flutter_lints/flutter.yaml analyzer: errors: invalid_annotation_target: ignore - enable-experiment: - - records linter: rules: From bc29b1afc39e1646cb78cb9b223c1e87aab8bb91 Mon Sep 17 00:00:00 2001 From: PCoder23 Date: Tue, 27 Feb 2024 17:28:33 +0530 Subject: [PATCH 10/24] added more headers --- lib/utils/header_utils.dart | 58 ++++++++++++++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/lib/utils/header_utils.dart b/lib/utils/header_utils.dart index 45a24fe9..20f975cb 100644 --- a/lib/utils/header_utils.dart +++ b/lib/utils/header_utils.dart @@ -1,5 +1,9 @@ + Map headers = { + "Age": "It is a response header. It defines the times in seconds of the object that have been in the proxy cache.", "Accept": "Specifies the media types that are acceptable for the response.", + "Accept-charset": + "It is a request type header. This header is used to indicate what character set are acceptable for the response from the server.", "Accept-Encoding": "Indicates the encoding methods the client can understand.", "Access-Control-Allow-Headers": @@ -16,11 +20,19 @@ Map headers = { "Used in preflight requests during CORS to indicate the HTTP method that will be used in the actual request.", "Accept-Language": "Specifies the preferred natural language and locale for the response.", + "Accept-CH": + "It is a response-type header. It specify which Client Hints headers client should include in subsequent requests.", + "Accept-CH-Lifetime": + "It is a response-type header used to specify persistence of Accept-CH header value.", "Authorization": "Contains credentials for authenticating the client with the server.", "Authorization Bearer Token": "Often used for token-based authentication.", + "Alt-Svc": + "It is use to reach the website in an alternate way.", "Cache-Control": "Provides directives for caching mechanisms in both requests and responses.", + "Clear-Site-Data": + "It is a response-type header. This header is used in deleting the browsing data which is in the requesting website.", "Connection": "Informs whether the connection stays open or close after the current transaction finishes.", "Content-Disposition": @@ -30,7 +42,7 @@ Map headers = { "Content-Length": "Indicates the size of the message body sent to the recipient in bytes.", "Content-Security-Policy": - "Controls the sources from which content can be loaded on a web page to mitigate various types of attacks.", + "Controls the sources from which content can be loaded on a web page to mitigate various types of attacks.", "Content-Type": "Indicates the original media type of the resource (prior to any content encoding applied for sending)", "Cookie": "Used to send previously stored cookies back to the server.", @@ -40,9 +52,18 @@ Map headers = { "Controls which documents are allowed to open a new window or access the current window.", "Cross-Origin-Resource-Policy": "Controls how cross-origin requests for resources are handled.", + "Content-DPR": + "It is a response-type header. It is used to define the ratio between physical pixels over CSS pixels of the selected image response.", + "DPR": "It is response-type header, It is used to defines the ratio of the physical pixels over the CSS pixels of the current window of the device.", + "Device-Memory": + "It is used to specify the approximate ram left on the client device.", "Date": "Indicates the date and time at which the message was sent.", "DNT": "Informs websites whether the user's preference is to opt out of online tracking.", + "Early-Data": + "It is a request-type header. This header is used indicate that the request has been conveyed in early data.", + "ETag": + "It is a response-type header used as an identifier for a specific version of a resource.", "Expect": "Indicates certain expectations that need to be met by the server.", "Expires": "Contains the date/time after which the response is considered expired", @@ -57,9 +78,22 @@ Map headers = { "Used in conjunction with the Range header to conditionally request a partial resource.", "If-Unmodified-Since": "Used for conditional requests, allows the server to respond based on certain conditions.", + "Keep-Alive": + "It is a general-type header used to inform that how long a persistent connection should stay open.", + "Last-Modified": + "The last modified response header is a header sent by the server specifying the date of the last modification of the requested source. This is the formal definition of Last-Modified of HTTP headers.", "Location": "Indicates the URL a client should redirect to for further interaction.", + "Large-Allocation": + "It is a response-type header that informs supported browsers (currently only Firefox) about the needs of a memory that allows them to make sure that the large-allocation succeeds and also start a new process using some unfragmented memory.", + "Link": + "It is entity-type header used to serializing one or more links in HTTP headers.", "Origin": "Specifies the origin of a cross-origin request.", + "Proxy-Authenticate": "It is a response header gives access to a resource file by defining an authorization method. It allows the proxy server to transmit the request further by authenticating it.", + "Proxy-Authorization": + "It is a request type of header. This header contains the credentials to authenticate between the user agent and the user-specified server.", + "Pragma": + "It is general-type header, but response behavior is not specified and thus implementation-specific.", "Range": "Used to request only part of a resource, typically in the context of downloading large files.", "Referer": @@ -68,14 +102,34 @@ Map headers = { "Specifies how much information the browser should include in the Referer header when navigating to other pages.", "Retry-After": "Informs the client how long it should wait before making another request after a server has responded with a rate-limiting status code.", + "Save-Data": + "It is used to reduce the usage of the data on the client side.", "Server": "Indicates the software used by the origin server.", + "Server-Timing": + "It is a response-type header. This header is used to communicate between two or more metrics and descriptions for a given request-response cycle from the user agent.", + "SourceMap": + "It is a response-type header used to map original source from the transformed source. For example, the JavaScript resources are transformed to some other source from its original by the browsers at the time of execution.", "Strict-Transport-Security": "Instructs the browser to always use HTTPS for the given domain.", + "Timing-Allow-Origin": + "It is a response type header. It specify origins that are allowed to see values of attributes retrieved via features of the Resource Timing API.", + "TK": + "It is a response type header, it indicates the tracking status.", "TE": "Specifies the transfer encodings that are acceptable to the client.", "User-Agent": "Identifies the client software and version making the request.", + "Vary": + "It is response-type header. It is used by the server to indicate which headers it used when selecting a representation of a resource in a content negotiation algorithm.", "Via": "Indicates intermediate proxies or gateways through which the request or response has passed.", + "Viewport-Width": + "It is used to indicates the layout viewport width in CSS pixels.", + "Width": + "It is a request-type header. This header is used indicates the desired resource width in physical pixels.", + "Warnings": + "It is a general type header that is used to inform possible problems to the client.", + "WWW-Authenticate": + "It is a response header that defines the authentication method. It should be used to gain access to a resource.", "X-Api-Key": "Used to authenticate requests to an API with an API key.", "X-Content-Type-Options": "Used to prevent browsers from MIME-sniffing a response.", @@ -89,6 +143,8 @@ Map headers = { "Indicates whether the request was made with JavaScript using XMLHttpRequest.", "X-XSS-Protection": "Enables or disables the browser's built-in cross-site scripting (XSS) filter.", + "X-DNS-Prefetch-Control": + "It is response-type header that is used to control the DNS prefetch." }; List getHeaderSuggestions(String pattern) { From 4e3b4a1f9ce72163d067bbe7078bbe438840cdfb Mon Sep 17 00:00:00 2001 From: PCoder23 Date: Tue, 27 Feb 2024 17:54:54 +0530 Subject: [PATCH 11/24] updated header test --- test/utils/header_utils_test.dart | 42 ++++++++++++++++++++++++++++--- 1 file changed, 38 insertions(+), 4 deletions(-) diff --git a/test/utils/header_utils_test.dart b/test/utils/header_utils_test.dart index 73c15721..5605c66b 100644 --- a/test/utils/header_utils_test.dart +++ b/test/utils/header_utils_test.dart @@ -1,6 +1,36 @@ import 'package:apidash/utils/header_utils.dart'; import 'package:test/test.dart'; +// new headers +// X-DNS-Proxy-Authenticate +// Proxy-Authorization +// WWW-Authenticate +// Age +// Clear-Site-Data +// Pragma +// Warnings +// Accept-CH +// Accept-CH-Lifetime +// Content-DPR +// DPR +// Device-Memory +// Early-Data +// Save-Data +// Viewport-Width +// Width +// Last-Modified +// ETag +// Vary +// Keep-Alive +// Accept-charset +// Timing-Allow-Origin +// TK +// Alt-Svc +// Large-Allocation +// Link +// Server-Timing +// SourceMap +// X-DNS-Prefetch-Control void main() { group("Testing getHeaderSuggestions function", () { test("Testing using Allow-Headers", () { @@ -17,7 +47,7 @@ void main() { test("Testing using Allow-Origin", () { String pattern = "Allow-Origin"; - List expected = ["Access-Control-Allow-Origin"]; + List expected = ["Access-Control-Allow-Origin", "Timing-Allow-Origin"]; expect(getHeaderSuggestions(pattern), expected); }); @@ -93,7 +123,8 @@ void main() { List expected = [ "Access-Control-Allow-Headers", "Access-Control-Allow-Methods", - "Access-Control-Allow-Origin" + "Access-Control-Allow-Origin", + "Timing-Allow-Origin" ]; expect(getHeaderSuggestions(pattern), expected); }); @@ -106,6 +137,7 @@ void main() { 'Content-Length', 'Content-Security-Policy', 'Content-Type', + "Content-DPR", 'X-Content-Type-Options' ]; expect(getHeaderSuggestions(pattern), expected); @@ -121,7 +153,8 @@ void main() { "X-Forwarded-For", "X-Frame-Options", "X-Requested-With", - "X-XSS-Protection" + "X-XSS-Protection", + "X-DNS-Prefetch-Control", ]; expect(getHeaderSuggestions(pattern), expected); }); @@ -133,7 +166,8 @@ void main() { 'Cross-Origin-Embedder-Policy', 'Cross-Origin-Opener-Policy', 'Cross-Origin-Resource-Policy', - 'Origin' + 'Origin', + 'Timing-Allow-Origin' ]; expect(getHeaderSuggestions(pattern), expected); }); From 993621793a672c80b7fbc92bdaa846136fc342f7 Mon Sep 17 00:00:00 2001 From: Ashita Prasad Date: Tue, 27 Feb 2024 21:43:15 +0530 Subject: [PATCH 12/24] Delete analyze.yml --- .github/workflows/analyze.yml | 22 ---------------------- 1 file changed, 22 deletions(-) delete mode 100644 .github/workflows/analyze.yml diff --git a/.github/workflows/analyze.yml b/.github/workflows/analyze.yml deleted file mode 100644 index 0d5b1fb6..00000000 --- a/.github/workflows/analyze.yml +++ /dev/null @@ -1,22 +0,0 @@ -name: "Code Analysis" -on: [ push ] - - -jobs: - Flutter-Analyze: - runs-on: ubuntu-latest - steps: - - run: pwd - - name: Checkout Code - uses: actions/checkout@v3 - - - name: Get Flutter Env - uses: subosito/flutter-action@v2 - with: - channel: 'stable' - - run: flutter --version - - - name: Code Analysis - run: | - flutter pub get - flutter analyze From 6acca4cf87ce92b6624fc58f0040888b1e79b0cf Mon Sep 17 00:00:00 2001 From: PCoder23 Date: Thu, 29 Feb 2024 12:44:37 +0530 Subject: [PATCH 13/24] corrected added headers --- lib/utils/header_utils.dart | 70 +++++++------------------------ test/utils/header_utils_test.dart | 45 +++----------------- 2 files changed, 21 insertions(+), 94 deletions(-) diff --git a/lib/utils/header_utils.dart b/lib/utils/header_utils.dart index 20f975cb..101738a0 100644 --- a/lib/utils/header_utils.dart +++ b/lib/utils/header_utils.dart @@ -1,11 +1,8 @@ - Map headers = { - "Age": "It is a response header. It defines the times in seconds of the object that have been in the proxy cache.", "Accept": "Specifies the media types that are acceptable for the response.", - "Accept-charset": - "It is a request type header. This header is used to indicate what character set are acceptable for the response from the server.", "Accept-Encoding": "Indicates the encoding methods the client can understand.", + "Accept-Charset": "Specifies the character sets that are acceptable.", "Access-Control-Allow-Headers": "Specifies a list of HTTP headers that can be used in an actual request after a preflight request including the Access-Control-Request-Headers header is made.", "Access-Control-Allow-Methods": @@ -20,19 +17,11 @@ Map headers = { "Used in preflight requests during CORS to indicate the HTTP method that will be used in the actual request.", "Accept-Language": "Specifies the preferred natural language and locale for the response.", - "Accept-CH": - "It is a response-type header. It specify which Client Hints headers client should include in subsequent requests.", - "Accept-CH-Lifetime": - "It is a response-type header used to specify persistence of Accept-CH header value.", "Authorization": "Contains credentials for authenticating the client with the server.", "Authorization Bearer Token": "Often used for token-based authentication.", - "Alt-Svc": - "It is use to reach the website in an alternate way.", "Cache-Control": "Provides directives for caching mechanisms in both requests and responses.", - "Clear-Site-Data": - "It is a response-type header. This header is used in deleting the browsing data which is in the requesting website.", "Connection": "Informs whether the connection stays open or close after the current transaction finishes.", "Content-Disposition": @@ -42,7 +31,7 @@ Map headers = { "Content-Length": "Indicates the size of the message body sent to the recipient in bytes.", "Content-Security-Policy": - "Controls the sources from which content can be loaded on a web page to mitigate various types of attacks.", + "Controls the sources from which content can be loaded on a web page to mitigate various types of attacks.", "Content-Type": "Indicates the original media type of the resource (prior to any content encoding applied for sending)", "Cookie": "Used to send previously stored cookies back to the server.", @@ -52,21 +41,17 @@ Map headers = { "Controls which documents are allowed to open a new window or access the current window.", "Cross-Origin-Resource-Policy": "Controls how cross-origin requests for resources are handled.", - "Content-DPR": - "It is a response-type header. It is used to define the ratio between physical pixels over CSS pixels of the selected image response.", - "DPR": "It is response-type header, It is used to defines the ratio of the physical pixels over the CSS pixels of the current window of the device.", - "Device-Memory": - "It is used to specify the approximate ram left on the client device.", "Date": "Indicates the date and time at which the message was sent.", + "Device-Memory": + "Indicates the approximate amount of device memory in gigabytes.", "DNT": "Informs websites whether the user's preference is to opt out of online tracking.", - "Early-Data": - "It is a request-type header. This header is used indicate that the request has been conveyed in early data.", - "ETag": - "It is a response-type header used as an identifier for a specific version of a resource.", "Expect": "Indicates certain expectations that need to be met by the server.", "Expires": "Contains the date/time after which the response is considered expired", + "Forwarded": + "Contains information from the client-facing side of proxy servers that is altered or lost when a proxy is involved in the path of the request.", + "From": "Contains an Internet email address for a human user who controls the requesting user agent.", "Host": "Specifies the domain name of the server and the port number.", "If-Match": "Used for conditional requests, allows the server to respond based on certain conditions.", @@ -79,21 +64,14 @@ Map headers = { "If-Unmodified-Since": "Used for conditional requests, allows the server to respond based on certain conditions.", "Keep-Alive": - "It is a general-type header used to inform that how long a persistent connection should stay open.", - "Last-Modified": - "The last modified response header is a header sent by the server specifying the date of the last modification of the requested source. This is the formal definition of Last-Modified of HTTP headers.", + "Used to allow the connection to be reused for further requests.", "Location": "Indicates the URL a client should redirect to for further interaction.", - "Large-Allocation": - "It is a response-type header that informs supported browsers (currently only Firefox) about the needs of a memory that allows them to make sure that the large-allocation succeeds and also start a new process using some unfragmented memory.", - "Link": - "It is entity-type header used to serializing one or more links in HTTP headers.", + "Max-Forwards": + "Indicates the remaining number of times a request can be forwarded by proxies.", "Origin": "Specifies the origin of a cross-origin request.", - "Proxy-Authenticate": "It is a response header gives access to a resource file by defining an authorization method. It allows the proxy server to transmit the request further by authenticating it.", "Proxy-Authorization": - "It is a request type of header. This header contains the credentials to authenticate between the user agent and the user-specified server.", - "Pragma": - "It is general-type header, but response behavior is not specified and thus implementation-specific.", + "Contains credentials for authenticating a client with a proxy server.", "Range": "Used to request only part of a resource, typically in the context of downloading large files.", "Referer": @@ -103,33 +81,17 @@ Map headers = { "Retry-After": "Informs the client how long it should wait before making another request after a server has responded with a rate-limiting status code.", "Save-Data": - "It is used to reduce the usage of the data on the client side.", + "Indicates the client's preference for reduced data usage.", "Server": "Indicates the software used by the origin server.", - "Server-Timing": - "It is a response-type header. This header is used to communicate between two or more metrics and descriptions for a given request-response cycle from the user agent.", - "SourceMap": - "It is a response-type header used to map original source from the transformed source. For example, the JavaScript resources are transformed to some other source from its original by the browsers at the time of execution.", "Strict-Transport-Security": "Instructs the browser to always use HTTPS for the given domain.", - "Timing-Allow-Origin": - "It is a response type header. It specify origins that are allowed to see values of attributes retrieved via features of the Resource Timing API.", - "TK": - "It is a response type header, it indicates the tracking status.", "TE": "Specifies the transfer encodings that are acceptable to the client.", + "Upgrade-Insecure-Requests": + "Instructs the browser to prefer secure connections when available.", "User-Agent": "Identifies the client software and version making the request.", - "Vary": - "It is response-type header. It is used by the server to indicate which headers it used when selecting a representation of a resource in a content negotiation algorithm.", "Via": "Indicates intermediate proxies or gateways through which the request or response has passed.", - "Viewport-Width": - "It is used to indicates the layout viewport width in CSS pixels.", - "Width": - "It is a request-type header. This header is used indicates the desired resource width in physical pixels.", - "Warnings": - "It is a general type header that is used to inform possible problems to the client.", - "WWW-Authenticate": - "It is a response header that defines the authentication method. It should be used to gain access to a resource.", "X-Api-Key": "Used to authenticate requests to an API with an API key.", "X-Content-Type-Options": "Used to prevent browsers from MIME-sniffing a response.", @@ -143,8 +105,6 @@ Map headers = { "Indicates whether the request was made with JavaScript using XMLHttpRequest.", "X-XSS-Protection": "Enables or disables the browser's built-in cross-site scripting (XSS) filter.", - "X-DNS-Prefetch-Control": - "It is response-type header that is used to control the DNS prefetch." }; List getHeaderSuggestions(String pattern) { @@ -153,4 +113,4 @@ List getHeaderSuggestions(String pattern) { (element) => element.toLowerCase().contains(pattern.toLowerCase()), ) .toList(); -} +} \ No newline at end of file diff --git a/test/utils/header_utils_test.dart b/test/utils/header_utils_test.dart index 5605c66b..79e6ffd1 100644 --- a/test/utils/header_utils_test.dart +++ b/test/utils/header_utils_test.dart @@ -1,36 +1,6 @@ import 'package:apidash/utils/header_utils.dart'; import 'package:test/test.dart'; -// new headers -// X-DNS-Proxy-Authenticate -// Proxy-Authorization -// WWW-Authenticate -// Age -// Clear-Site-Data -// Pragma -// Warnings -// Accept-CH -// Accept-CH-Lifetime -// Content-DPR -// DPR -// Device-Memory -// Early-Data -// Save-Data -// Viewport-Width -// Width -// Last-Modified -// ETag -// Vary -// Keep-Alive -// Accept-charset -// Timing-Allow-Origin -// TK -// Alt-Svc -// Large-Allocation -// Link -// Server-Timing -// SourceMap -// X-DNS-Prefetch-Control void main() { group("Testing getHeaderSuggestions function", () { test("Testing using Allow-Headers", () { @@ -47,7 +17,7 @@ void main() { test("Testing using Allow-Origin", () { String pattern = "Allow-Origin"; - List expected = ["Access-Control-Allow-Origin", "Timing-Allow-Origin"]; + List expected = ["Access-Control-Allow-Origin"]; expect(getHeaderSuggestions(pattern), expected); }); @@ -123,8 +93,7 @@ void main() { List expected = [ "Access-Control-Allow-Headers", "Access-Control-Allow-Methods", - "Access-Control-Allow-Origin", - "Timing-Allow-Origin" + "Access-Control-Allow-Origin" ]; expect(getHeaderSuggestions(pattern), expected); }); @@ -137,7 +106,6 @@ void main() { 'Content-Length', 'Content-Security-Policy', 'Content-Type', - "Content-DPR", 'X-Content-Type-Options' ]; expect(getHeaderSuggestions(pattern), expected); @@ -147,14 +115,14 @@ void main() { String pattern = "x-"; List expected = [ "Access-Control-Max-Age", + "Max-Forwards", "X-Api-Key", "X-Content-Type-Options", "X-CSRF-Token", "X-Forwarded-For", "X-Frame-Options", "X-Requested-With", - "X-XSS-Protection", - "X-DNS-Prefetch-Control", + "X-XSS-Protection" ]; expect(getHeaderSuggestions(pattern), expected); }); @@ -166,10 +134,9 @@ void main() { 'Cross-Origin-Embedder-Policy', 'Cross-Origin-Opener-Policy', 'Cross-Origin-Resource-Policy', - 'Origin', - 'Timing-Allow-Origin' + 'Origin' ]; expect(getHeaderSuggestions(pattern), expected); }); }); -} +} \ No newline at end of file From 51be09b076d770c02bed24224e82f934a3380c12 Mon Sep 17 00:00:00 2001 From: PCoder23 Date: Thu, 29 Feb 2024 20:52:17 +0530 Subject: [PATCH 14/24] added the line back --- lib/utils/header_utils.dart | 2 +- test/utils/header_utils_test.dart | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/utils/header_utils.dart b/lib/utils/header_utils.dart index 101738a0..1450cc01 100644 --- a/lib/utils/header_utils.dart +++ b/lib/utils/header_utils.dart @@ -113,4 +113,4 @@ List getHeaderSuggestions(String pattern) { (element) => element.toLowerCase().contains(pattern.toLowerCase()), ) .toList(); -} \ No newline at end of file +} diff --git a/test/utils/header_utils_test.dart b/test/utils/header_utils_test.dart index 79e6ffd1..139ba553 100644 --- a/test/utils/header_utils_test.dart +++ b/test/utils/header_utils_test.dart @@ -139,4 +139,4 @@ void main() { expect(getHeaderSuggestions(pattern), expected); }); }); -} \ No newline at end of file +} From ad05c3f32708b47e8312d078d0eef26f03988b27 Mon Sep 17 00:00:00 2001 From: Chinmay Chaudhari Date: Thu, 29 Feb 2024 23:27:31 +0530 Subject: [PATCH 15/24] Added vertical scrolling --- lib/widgets/csv_previewer.dart | 52 ++++++++++++++++++---------------- 1 file changed, 28 insertions(+), 24 deletions(-) diff --git a/lib/widgets/csv_previewer.dart b/lib/widgets/csv_previewer.dart index cdfc45b0..d3b88261 100644 --- a/lib/widgets/csv_previewer.dart +++ b/lib/widgets/csv_previewer.dart @@ -11,36 +11,40 @@ class CsvPreviewer extends StatelessWidget { @override Widget build(BuildContext context) { try { - final List> csvData = const CsvToListConverter().convert(body, eol: '\n'); - return SingleChildScrollView( + final List> csvData = + const CsvToListConverter().convert(body, eol: '\n'); + return SingleChildScrollView( + scrollDirection: Axis.vertical, + child: SingleChildScrollView( scrollDirection: Axis.horizontal, child: DataTable( columns: csvData[0] - .map( - (item) => DataColumn( - label: Text( - item.toString(), + .map( + (item) => DataColumn( + label: Text( + item.toString(), + ), ), - ), - ) - .toList(), + ) + .toList(), rows: csvData - .skip(1) - .map( - (csvrow) => DataRow( - cells: csvrow - .map( - (csvItem) => DataCell( - Text( - csvItem.toString(), - ), - ), - ) - .toList(), - ), - ) - .toList(), + .skip(1) + .map( + (csvrow) => DataRow( + cells: csvrow + .map( + (csvItem) => DataCell( + Text( + csvItem.toString(), + ), + ), + ) + .toList(), + ), + ) + .toList(), ), + ), ); } catch (e) { return const ErrorMessage(message: kCsvError); From dc25c6a70edacdcd7820f5e2eeba64a906406cc8 Mon Sep 17 00:00:00 2001 From: Ashita Prasad Date: Fri, 1 Mar 2024 01:10:49 +0530 Subject: [PATCH 16/24] Updated csv_previewer --- analysis_options.yaml | 3 +++ lib/consts.dart | 3 +-- lib/widgets/csv_previewer.dart | 6 +++--- lib/widgets/json_previewer.dart | 1 + lib/widgets/previewer.dart | 9 ++------- pubspec.lock | 8 ++++++++ test/widget_test.dart | 3 +++ 7 files changed, 21 insertions(+), 12 deletions(-) diff --git a/analysis_options.yaml b/analysis_options.yaml index bde061bb..9a1eabb4 100644 --- a/analysis_options.yaml +++ b/analysis_options.yaml @@ -3,6 +3,9 @@ include: package:flutter_lints/flutter.yaml analyzer: errors: invalid_annotation_target: ignore + exclude: + - "**/*.freezed.dart" + - "**/*.g.dart" linter: rules: diff --git a/lib/consts.dart b/lib/consts.dart index 4aba147f..d157b7fa 100644 --- a/lib/consts.dart +++ b/lib/consts.dart @@ -378,7 +378,7 @@ const Map>> kSubTypeDefaultViewOptions: kRawBodyViewOptions, kSubTypeCss: kCodeRawBodyViewOptions, kSubTypeHtml: kCodeRawBodyViewOptions, - kSubTypeCsv: kPreviewCodeRawBodyViewOptions, + kSubTypeCsv: kPreviewRawBodyViewOptions, kSubTypeJavascript: kCodeRawBodyViewOptions, kSubTypeMarkdown: kCodeRawBodyViewOptions, kSubTypeTextXml: kCodeRawBodyViewOptions, @@ -499,7 +499,6 @@ const kRaiseIssue = const kCsvError = "There seems to be an issue rendering this CSV. Please raise an issue in API Dash GitHub repo so that we can resolve it."; - const kHintTextUrlCard = "Enter API endpoint like api.foss42.com/country/codes"; const kLabelPlusNew = "+ New"; const kLabelSend = "Send"; diff --git a/lib/widgets/csv_previewer.dart b/lib/widgets/csv_previewer.dart index d3b88261..17e8dd48 100644 --- a/lib/widgets/csv_previewer.dart +++ b/lib/widgets/csv_previewer.dart @@ -1,10 +1,10 @@ import 'package:flutter/material.dart'; import 'package:csv/csv.dart'; -import 'package:apidash/consts.dart'; -import 'package:apidash/widgets/widgets.dart'; +import 'error_message.dart'; +import '../consts.dart'; class CsvPreviewer extends StatelessWidget { - const CsvPreviewer({Key? key, required this.body}) : super(key: key); + const CsvPreviewer({super.key, required this.body}); final String body; diff --git a/lib/widgets/json_previewer.dart b/lib/widgets/json_previewer.dart index 078a9721..46d066bf 100644 --- a/lib/widgets/json_previewer.dart +++ b/lib/widgets/json_previewer.dart @@ -154,6 +154,7 @@ class _JsonPreviewerState extends State { @override void didUpdateWidget(JsonPreviewer oldWidget) { + super.didUpdateWidget(oldWidget); if (oldWidget.code != widget.code) { store.buildNodes(widget.code, areAllCollapsed: true); store.expandAll(); diff --git a/lib/widgets/previewer.dart b/lib/widgets/previewer.dart index 6a6eb828..dd2f5186 100644 --- a/lib/widgets/previewer.dart +++ b/lib/widgets/previewer.dart @@ -1,5 +1,4 @@ import 'dart:convert'; -import 'package:apidash/widgets/csv_previewer.dart'; import 'package:flutter/foundation.dart'; import 'package:flutter/material.dart'; import 'package:printing/printing.dart'; @@ -8,6 +7,7 @@ import 'package:vector_graphics_compiler/vector_graphics_compiler.dart'; import 'error_message.dart'; import 'uint8_audio_player.dart'; import 'json_previewer.dart'; +import 'csv_previewer.dart'; import '../consts.dart'; class Previewer extends StatefulWidget { @@ -83,11 +83,7 @@ class _PreviewerState extends State { ); } if (widget.type == kTypeText && widget.subtype == kSubTypeCsv) { - try { - return CsvPreviewer(body: widget.body); - } catch (e) { - return const ErrorMessage(message: kCsvError); - } + return CsvPreviewer(body: widget.body); } if (widget.type == kTypeVideo) { // TODO: Video Player @@ -97,5 +93,4 @@ class _PreviewerState extends State { : "$kMimeTypeRaiseIssueStart${widget.type}/${widget.subtype}$kMimeTypeRaiseIssue"; return ErrorMessage(message: message); } - } diff --git a/pubspec.lock b/pubspec.lock index 70dda7d5..f48a9105 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -217,6 +217,14 @@ packages: url: "https://pub.dev" source: hosted version: "3.0.3" + csv: + dependency: "direct main" + description: + name: csv + sha256: "63ed2871dd6471193dffc52c0e6c76fb86269c00244d244297abbb355c84a86e" + url: "https://pub.dev" + source: hosted + version: "5.1.1" dart_style: dependency: "direct main" description: diff --git a/test/widget_test.dart b/test/widget_test.dart index 48eb1d93..3f806c72 100644 --- a/test/widget_test.dart +++ b/test/widget_test.dart @@ -1,3 +1,6 @@ +// ignore_for_file: unused_import +// TODO: Added ignore to calculate code coverage + import 'package:apidash/main.dart'; import 'package:apidash/app.dart'; import 'package:apidash/common/utils.dart'; From e14446f2e34cb737dce76b280c86d1cc8dc23d91 Mon Sep 17 00:00:00 2001 From: Yousef Rabia Date: Fri, 1 Mar 2024 17:18:42 +0200 Subject: [PATCH 17/24] Replace `tester.pumpAndSettle();` with `tester.pump();` Replacing `tester.pumpAndSettle();` with `tester.pump();` resolves an issue where `pumpAndSettle()` waits for all animations to complete, causing an infinite loop with `CircularProgressIndicator`. Using `pump()` ensures efficient frame building without unnecessary animation waiting. --- test/widgets/intro_message_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/widgets/intro_message_test.dart b/test/widgets/intro_message_test.dart index 798afad8..11ca1ad5 100644 --- a/test/widgets/intro_message_test.dart +++ b/test/widgets/intro_message_test.dart @@ -13,7 +13,7 @@ void main() { ), ); - await tester.pumpAndSettle(); + await tester.pump(); expect(find.text('Welcome to API Dash ⚡️'), findsOneWidget); expect(find.byType(RichText), findsAtLeastNWidgets(1)); From 1db5d88125d0d584d28f5cd21b1ed00b4c68be2f Mon Sep 17 00:00:00 2001 From: Yousef Rabia Date: Fri, 1 Mar 2024 17:20:40 +0200 Subject: [PATCH 18/24] Ensure introData() Function Works During Testing by Using `setMockInitialValues` --- test/widgets/intro_message_test.dart | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/test/widgets/intro_message_test.dart b/test/widgets/intro_message_test.dart index 11ca1ad5..d5e543bd 100644 --- a/test/widgets/intro_message_test.dart +++ b/test/widgets/intro_message_test.dart @@ -1,9 +1,16 @@ import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; import 'package:apidash/widgets/intro_message.dart'; +import 'package:package_info_plus/package_info_plus.dart'; void main() { testWidgets('Testing Intro Message', (tester) async { + PackageInfo.setMockInitialValues( + appName: 'API Dash', + packageName: 'dev.apidash.apidash', + version: '1.0.0', + buildNumber: '1', + buildSignature: 'buildSignature'); await tester.pumpWidget( const MaterialApp( title: 'Intro Message', From 00f008d8a2e479ac20d980530ef10b4cb0bcc884 Mon Sep 17 00:00:00 2001 From: Yousef Rabia Date: Fri, 1 Mar 2024 17:21:13 +0200 Subject: [PATCH 19/24] remove `skip:true` --- test/widgets/intro_message_test.dart | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/widgets/intro_message_test.dart b/test/widgets/intro_message_test.dart index d5e543bd..4e256c82 100644 --- a/test/widgets/intro_message_test.dart +++ b/test/widgets/intro_message_test.dart @@ -32,5 +32,5 @@ void main() { expect(find.byIcon(Icons.star), findsOneWidget); expect(find.text('Star on GitHub'), findsOneWidget); await tester.tap(find.byIcon(Icons.star)); - }, skip: true); + }); } From f2810865f2d003f64e6f70eb87f74a2cf65a21c2 Mon Sep 17 00:00:00 2001 From: Chinmay Date: Sat, 2 Mar 2024 20:49:06 +0530 Subject: [PATCH 20/24] Csv Added in readme --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 15dc46e1..7907373d 100644 --- a/README.md +++ b/README.md @@ -185,6 +185,10 @@ Here is the complete list of mimetypes that are syntax highlighted in API Dash: | `text/html` | `.html` | Only syntax highlighting, no web preview. | | `text/javascript` | `.js` | | | `text/markdown` | `.md` | | +| `text/csv` | `. +csv` | +Renders CSV in table format. + | ## What's new in v0.3.0? From 30698ffce4f5014a766b4e88b592b60951df2a2d Mon Sep 17 00:00:00 2001 From: Chinmay Date: Sat, 2 Mar 2024 20:52:27 +0530 Subject: [PATCH 21/24] Table format corrected --- README.md | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/README.md b/README.md index 7907373d..6742de06 100644 --- a/README.md +++ b/README.md @@ -185,10 +185,7 @@ Here is the complete list of mimetypes that are syntax highlighted in API Dash: | `text/html` | `.html` | Only syntax highlighting, no web preview. | | `text/javascript` | `.js` | | | `text/markdown` | `.md` | | -| `text/csv` | `. -csv` | -Renders CSV in table format. - | +| `text/csv` | `.csv` | Renders CSV in tabular form | ## What's new in v0.3.0? From d95d497c9c8478217ebf6a1ccdebe2791f665cbc Mon Sep 17 00:00:00 2001 From: Chinmay Date: Sat, 2 Mar 2024 20:53:12 +0530 Subject: [PATCH 22/24] Type fixed --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 6742de06..ab08478a 100644 --- a/README.md +++ b/README.md @@ -185,7 +185,7 @@ Here is the complete list of mimetypes that are syntax highlighted in API Dash: | `text/html` | `.html` | Only syntax highlighting, no web preview. | | `text/javascript` | `.js` | | | `text/markdown` | `.md` | | -| `text/csv` | `.csv` | Renders CSV in tabular form | +| `text/csv` | `.csv` | Renders CSV in tabular format | ## What's new in v0.3.0? From e20ead29344acd6478b4f6cc619d87922aa1ae74 Mon Sep 17 00:00:00 2001 From: Ashita Prasad Date: Sun, 3 Mar 2024 06:35:50 +0530 Subject: [PATCH 23/24] Update README.md --- README.md | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index ab08478a..d8b258e5 100644 --- a/README.md +++ b/README.md @@ -137,6 +137,7 @@ Here is the complete list of mimetypes that can be directly previewed in API Das | File Type | Mimetype | Extension | Comment | | --------- | -------------------------- | ----------------- | -------- | | PDF | `application/pdf` | `.pdf` | | +| CSV | `text/csv` | `.csv` | Can be improved | | Image | `image/apng` | `.apng` | Animated | | Image | `image/avif` | `.avif` | | | Image | `image/bmp` | `.bmp` | | @@ -177,15 +178,14 @@ Here is the complete list of mimetypes that are syntax highlighted in API Dash: | ------------------ | --------- | ------------------------------------------------------------------------------------------------------------------ | | `application/json` | `.json` | Other mimetypes like `application/geo+json`, `application/vcard+json` that are based on `json` are also supported. | | `application/xml` | `.xml` | Other mimetypes like `application/xhtml+xml`, `application/vcard+xml` that are based on `xml` are also supported. | -| `text/xml` | `.xml` | | -| `application/yaml` | `.yaml` | Others - `application/x-yaml` or `application/x-yml` | -| `text/yaml` | `.yaml` | Others - `text/yml` | -| `application/sql` | `.sql` | | -| `text/css` | `.css` | | -| `text/html` | `.html` | Only syntax highlighting, no web preview. | -| `text/javascript` | `.js` | | -| `text/markdown` | `.md` | | -| `text/csv` | `.csv` | Renders CSV in tabular format | +| `text/xml` | `.xml` | | +| `application/yaml` | `.yaml` | Others - `application/x-yaml` or `application/x-yml` | +| `text/yaml` | `.yaml` | Others - `text/yml` | +| `application/sql` | `.sql` | | +| `text/css` | `.css` | | +| `text/html` | `.html` | Only syntax highlighting, no web preview. | +| `text/javascript` | `.js` | | +| `text/markdown` | `.md` | | ## What's new in v0.3.0? From 6a886df6694a42d60a5465988f6b7b1a827e81c5 Mon Sep 17 00:00:00 2001 From: Ankit Mahato Date: Sun, 3 Mar 2024 13:35:07 +0530 Subject: [PATCH 24/24] Update pull_request_template.md --- .github/pull_request_template.md | 1 - 1 file changed, 1 deletion(-) diff --git a/.github/pull_request_template.md b/.github/pull_request_template.md index 721b55e6..04873dba 100644 --- a/.github/pull_request_template.md +++ b/.github/pull_request_template.md @@ -16,4 +16,3 @@ _We encourage you to add relevant test cases._ - [ ] Yes - [ ] No, and this is why: _please replace this line with details on why tests have not been included_ -- [ ] I need help with writing tests