mirror of
https://github.com/foss42/apidash.git
synced 2025-06-29 04:16:12 +08:00
FileType -> ImportFormat
This commit is contained in:
@ -348,8 +348,11 @@ enum CodegenLanguage {
|
|||||||
final String ext;
|
final String ext;
|
||||||
}
|
}
|
||||||
|
|
||||||
enum FileType {
|
enum ImportFormat {
|
||||||
curl,
|
curl("cURL");
|
||||||
|
|
||||||
|
const ImportFormat(this.label);
|
||||||
|
final String label;
|
||||||
}
|
}
|
||||||
|
|
||||||
const JsonEncoder kEncoder = JsonEncoder.withIndent(' ');
|
const JsonEncoder kEncoder = JsonEncoder.withIndent(' ');
|
||||||
|
@ -3,9 +3,10 @@ import 'package:apidash/fileimport/curl/curl.dart';
|
|||||||
import 'package:apidash/models/request_model.dart';
|
import 'package:apidash/models/request_model.dart';
|
||||||
|
|
||||||
class FileImport {
|
class FileImport {
|
||||||
Future<RequestModel?> getRequestModel(FileType fileType, String contents, String newId) async {
|
Future<RequestModel?> getRequestModel(
|
||||||
|
ImportFormat fileType, String contents, String newId) async {
|
||||||
switch (fileType) {
|
switch (fileType) {
|
||||||
case FileType.curl:
|
case ImportFormat.curl:
|
||||||
return CurlFileImport().getRequestModel(contents, newId);
|
return CurlFileImport().getRequestModel(contents, newId);
|
||||||
default:
|
default:
|
||||||
return null;
|
return null;
|
||||||
|
@ -47,7 +47,7 @@ class CollectionPane extends ConsumerWidget {
|
|||||||
final newId = ref.watch(selectedIdStateProvider)!;
|
final newId = ref.watch(selectedIdStateProvider)!;
|
||||||
final i = file.path.lastIndexOf('.') + 1;
|
final i = file.path.lastIndexOf('.') + 1;
|
||||||
final String ext = file.path.substring(i);
|
final String ext = file.path.substring(i);
|
||||||
final fileType = FileType.values.byName(ext);
|
final fileType = ImportFormat.values.byName(ext);
|
||||||
file.readAsString().then((contents) {
|
file.readAsString().then((contents) {
|
||||||
fileImport
|
fileImport
|
||||||
.getRequestModel(fileType, contents, newId)
|
.getRequestModel(fileType, contents, newId)
|
||||||
|
Reference in New Issue
Block a user