From e08b40cfb6b09b3842723b83a0dcf0a4d428cb32 Mon Sep 17 00:00:00 2001 From: Ashita Prasad <ashitaprasad92@gmail.com> Date: Mon, 1 Jan 2024 09:32:35 +0530 Subject: [PATCH] Revert "feat: ability to override content type" This reverts commit e0fe907d194440893c5a1c964d15600284bd209c. --- lib/consts.dart | 2 -- .../request_pane/request_headers.dart | 18 ------------------ lib/utils/header_utils.dart | 11 ----------- lib/widgets/headerfield.dart | 6 +----- 4 files changed, 1 insertion(+), 36 deletions(-) diff --git a/lib/consts.dart b/lib/consts.dart index 39cb0dbb..d881fb86 100644 --- a/lib/consts.dart +++ b/lib/consts.dart @@ -305,8 +305,6 @@ const kTypeVideo = 'video'; const kSubTypeDefaultViewOptions = 'all'; -const kContentType = 'Content-Type'; - const kContentTypeMap = { ContentType.json: "$kTypeApplication/$kSubTypeJson", ContentType.text: "$kTypeText/$kSubTypePlain", diff --git a/lib/screens/home_page/editor_pane/details_card/request_pane/request_headers.dart b/lib/screens/home_page/editor_pane/details_card/request_pane/request_headers.dart index 0f2cf728..82138db5 100644 --- a/lib/screens/home_page/editor_pane/details_card/request_pane/request_headers.dart +++ b/lib/screens/home_page/editor_pane/details_card/request_pane/request_headers.dart @@ -1,5 +1,4 @@ import 'dart:math'; -import 'package:apidash/utils/header_utils.dart'; import 'package:flutter/material.dart'; import 'package:flutter_riverpod/flutter_riverpod.dart'; import 'package:davi/davi.dart'; @@ -79,23 +78,6 @@ class EditRequestHeadersState extends ConsumerState<EditRequestHeaders> { grow: 1, cellBuilder: (_, row) { int idx = row.index; - - if (row.data.name == kContentType) { - return HeaderField( - keyId: "$activeId-$idx-headers-v-$seed", - initialValue: rows[idx].value, - hintText: " Add Header Value", - onChanged: (value) { - rows[idx] = rows[idx].copyWith(value: value); - _onFieldChange(activeId!); - }, - headerSuggestionsCallback: (pattern) { - return getHeaderValueSuggestions(pattern); - }, - colorScheme: Theme.of(context).colorScheme, - ); - } - return CellField( keyId: "$activeId-$idx-headers-v-$seed", initialValue: rows[idx].value, diff --git a/lib/utils/header_utils.dart b/lib/utils/header_utils.dart index de13f8b4..63a456ef 100644 --- a/lib/utils/header_utils.dart +++ b/lib/utils/header_utils.dart @@ -15,7 +15,6 @@ Map<String, String> headers = { "Indicates the encoding transformations that have been applied to the entity body of the response.", "Content-Security-Policy": "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.", "Cross-Origin-Embedder-Policy": "Controls whether a document is allowed to be embedded in another document.", @@ -71,13 +70,3 @@ List<String> getHeaderSuggestions(String pattern) { ) .toList(); } - -List<String> headerValues = ['application/json', 'text/plain']; - -List<String> getHeaderValueSuggestions(String pattern) { - return headerValues - .where( - (element) => element.contains(pattern.toLowerCase()), - ) - .toList(); -} diff --git a/lib/widgets/headerfield.dart b/lib/widgets/headerfield.dart index 4ff548e3..9c678ee3 100644 --- a/lib/widgets/headerfield.dart +++ b/lib/widgets/headerfield.dart @@ -1,5 +1,3 @@ -import 'dart:async'; - import 'package:apidash/utils/header_utils.dart'; import 'package:flutter/material.dart'; import 'package:apidash/consts.dart'; @@ -12,14 +10,12 @@ class HeaderField extends StatefulWidget { this.hintText, this.initialValue, this.onChanged, - this.headerSuggestionsCallback, this.colorScheme, }); final String keyId; final String? hintText; final String? initialValue; final void Function(String)? onChanged; - final FutureOr<Iterable<String>> Function(String)? headerSuggestionsCallback; final ColorScheme? colorScheme; @override @@ -71,7 +67,7 @@ class _HeaderFieldState extends State<HeaderField> { title: Text(suggestion), ); }, - suggestionsCallback: widget.headerSuggestionsCallback ?? headerSuggestionCallback, + suggestionsCallback: headerSuggestionCallback, suggestionsBoxDecoration: suggestionBoxDecorations(context), textFieldConfiguration: TextFieldConfiguration( onChanged: widget.onChanged,