Update HTTPVerb

This commit is contained in:
Ashita Prasad
2024-12-22 02:38:40 +05:30
parent 301aa82731
commit d7566716ba
3 changed files with 29 additions and 39 deletions

View File

@ -28,27 +28,14 @@ Color getResponseStatusCodeColor(int? statusCode,
Color getHTTPMethodColor(HTTPVerb method,
{Brightness brightness = Brightness.light}) {
Color col;
switch (method) {
case HTTPVerb.get:
col = kColorHttpMethodGet;
break;
case HTTPVerb.head:
col = kColorHttpMethodHead;
break;
case HTTPVerb.post:
col = kColorHttpMethodPost;
break;
case HTTPVerb.put:
col = kColorHttpMethodPut;
break;
case HTTPVerb.patch:
col = kColorHttpMethodPatch;
break;
case HTTPVerb.delete:
col = kColorHttpMethodDelete;
break;
}
Color col = switch (method) {
HTTPVerb.get => kColorHttpMethodGet,
HTTPVerb.head => kColorHttpMethodHead,
HTTPVerb.post => kColorHttpMethodPost,
HTTPVerb.put => kColorHttpMethodPut,
HTTPVerb.patch => kColorHttpMethodPatch,
HTTPVerb.delete => kColorHttpMethodDelete,
};
if (brightness == Brightness.dark) {
col = getDarkModeColor(col);
}
@ -73,12 +60,9 @@ double? getJsonPreviewerMaxRootNodeWidth(double w) {
}
GlobalKey<ScaffoldState> getScaffoldKey(int railIdx) {
switch (railIdx) {
case 1:
return kEnvScaffoldKey;
case 2:
return kHisScaffoldKey;
default:
return kHomeScaffoldKey;
}
return switch (railIdx) {
1 => kEnvScaffoldKey,
2 => kHisScaffoldKey,
_ => kHomeScaffoldKey,
};
}

View File

@ -4,22 +4,18 @@ import 'package:flutter/material.dart';
import 'package:apidash/utils/utils.dart';
class MethodBox extends StatelessWidget {
const MethodBox({super.key, required this.method});
const MethodBox({
super.key,
required this.method,
});
final HTTPVerb method;
@override
Widget build(BuildContext context) {
String text = method.name.toUpperCase();
if (method == HTTPVerb.delete) {
text = "DEL";
}
if (method == HTTPVerb.patch) {
text = "PAT";
}
return SizedBox(
width: 24,
child: Text(
text,
method.abbr,
textAlign: TextAlign.center,
style: TextStyle(
fontSize: 8,

View File

@ -7,7 +7,17 @@ enum APIType {
final String label;
}
enum HTTPVerb { get, head, post, put, patch, delete }
enum HTTPVerb {
get("GET"),
head("HEAD"),
post("POST"),
put("PUT"),
patch("PAT"),
delete("DEL");
const HTTPVerb(this.abbr);
final String abbr;
}
enum SupportedUriSchemes { https, http }