mirror of
https://github.com/foss42/apidash.git
synced 2025-05-23 01:06:46 +08:00
freezed NameValueModel
This commit is contained in:
@ -47,7 +47,7 @@ val body = "${requestModel.requestBody}".toRequestBody(mediaType)\n""";
|
|||||||
}
|
}
|
||||||
for (final queryParam in requestModel.requestParams!) {
|
for (final queryParam in requestModel.requestParams!) {
|
||||||
result =
|
result =
|
||||||
"""$result .addQueryParameter("${queryParam.k}", "${queryParam.v}")\n""";
|
"""$result .addQueryParameter("${queryParam.name}", "${queryParam.value}")\n""";
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -58,7 +58,7 @@ val body = "${requestModel.requestBody}".toRequestBody(mediaType)\n""";
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
for (final header in requestModel.requestHeaders!) {
|
for (final header in requestModel.requestHeaders!) {
|
||||||
result = """$result .addHeader("${header.k}", "${header.v}")\n""";
|
result = """$result .addHeader("${header.name}", "${header.value}")\n""";
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -1,38 +1,17 @@
|
|||||||
import 'package:flutter/material.dart';
|
import 'package:freezed_annotation/freezed_annotation.dart';
|
||||||
|
import 'package:flutter/foundation.dart';
|
||||||
|
|
||||||
@immutable
|
part 'name_value_model.freezed.dart';
|
||||||
class NameValueModel {
|
|
||||||
const NameValueModel(this.k, this.v);
|
|
||||||
|
|
||||||
final String k;
|
part 'name_value_model.g.dart';
|
||||||
final dynamic v;
|
|
||||||
|
|
||||||
NameValueModel copyWith({
|
@freezed
|
||||||
String? k,
|
class NameValueModel with _$NameValueModel {
|
||||||
dynamic v,
|
const factory NameValueModel({
|
||||||
}) {
|
required String name,
|
||||||
return NameValueModel(k ?? this.k, v ?? this.v);
|
required dynamic value,
|
||||||
}
|
}) = _NameValueModel;
|
||||||
|
|
||||||
@override
|
factory NameValueModel.fromJson(Map<String, Object?> json) =>
|
||||||
String toString() {
|
_$NameValueModelFromJson(json);
|
||||||
return {k: v}.toString();
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
bool operator ==(Object other) {
|
|
||||||
return other is NameValueModel &&
|
|
||||||
other.runtimeType == runtimeType &&
|
|
||||||
other.k == k &&
|
|
||||||
other.v == v;
|
|
||||||
}
|
|
||||||
|
|
||||||
@override
|
|
||||||
int get hashCode {
|
|
||||||
return Object.hash(
|
|
||||||
runtimeType,
|
|
||||||
k,
|
|
||||||
v,
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
181
lib/models/name_value_model.freezed.dart
Normal file
181
lib/models/name_value_model.freezed.dart
Normal file
@ -0,0 +1,181 @@
|
|||||||
|
// coverage:ignore-file
|
||||||
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||||
|
// ignore_for_file: type=lint
|
||||||
|
// ignore_for_file: unused_element, deprecated_member_use, deprecated_member_use_from_same_package, use_function_type_syntax_for_parameters, unnecessary_const, avoid_init_to_null, invalid_override_different_default_values_named, prefer_expression_function_bodies, annotate_overrides, invalid_annotation_target, unnecessary_question_mark
|
||||||
|
|
||||||
|
part of 'name_value_model.dart';
|
||||||
|
|
||||||
|
// **************************************************************************
|
||||||
|
// FreezedGenerator
|
||||||
|
// **************************************************************************
|
||||||
|
|
||||||
|
T _$identity<T>(T value) => value;
|
||||||
|
|
||||||
|
final _privateConstructorUsedError = UnsupportedError(
|
||||||
|
'It seems like you constructed your class using `MyClass._()`. This constructor is only meant to be used by freezed and you are not supposed to need it nor use it.\nPlease check the documentation here for more information: https://github.com/rrousselGit/freezed#custom-getters-and-methods');
|
||||||
|
|
||||||
|
NameValueModel _$NameValueModelFromJson(Map<String, dynamic> json) {
|
||||||
|
return _NameValueModel.fromJson(json);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
mixin _$NameValueModel {
|
||||||
|
String get name => throw _privateConstructorUsedError;
|
||||||
|
dynamic get value => throw _privateConstructorUsedError;
|
||||||
|
|
||||||
|
Map<String, dynamic> toJson() => throw _privateConstructorUsedError;
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
$NameValueModelCopyWith<NameValueModel> get copyWith =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class $NameValueModelCopyWith<$Res> {
|
||||||
|
factory $NameValueModelCopyWith(
|
||||||
|
NameValueModel value, $Res Function(NameValueModel) then) =
|
||||||
|
_$NameValueModelCopyWithImpl<$Res, NameValueModel>;
|
||||||
|
@useResult
|
||||||
|
$Res call({String name, dynamic value});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class _$NameValueModelCopyWithImpl<$Res, $Val extends NameValueModel>
|
||||||
|
implements $NameValueModelCopyWith<$Res> {
|
||||||
|
_$NameValueModelCopyWithImpl(this._value, this._then);
|
||||||
|
|
||||||
|
// ignore: unused_field
|
||||||
|
final $Val _value;
|
||||||
|
// ignore: unused_field
|
||||||
|
final $Res Function($Val) _then;
|
||||||
|
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@override
|
||||||
|
$Res call({
|
||||||
|
Object? name = null,
|
||||||
|
Object? value = freezed,
|
||||||
|
}) {
|
||||||
|
return _then(_value.copyWith(
|
||||||
|
name: null == name
|
||||||
|
? _value.name
|
||||||
|
: name // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
value: freezed == value
|
||||||
|
? _value.value
|
||||||
|
: value // ignore: cast_nullable_to_non_nullable
|
||||||
|
as dynamic,
|
||||||
|
) as $Val);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
abstract class _$$_NameValueModelCopyWith<$Res>
|
||||||
|
implements $NameValueModelCopyWith<$Res> {
|
||||||
|
factory _$$_NameValueModelCopyWith(
|
||||||
|
_$_NameValueModel value, $Res Function(_$_NameValueModel) then) =
|
||||||
|
__$$_NameValueModelCopyWithImpl<$Res>;
|
||||||
|
@override
|
||||||
|
@useResult
|
||||||
|
$Res call({String name, dynamic value});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
class __$$_NameValueModelCopyWithImpl<$Res>
|
||||||
|
extends _$NameValueModelCopyWithImpl<$Res, _$_NameValueModel>
|
||||||
|
implements _$$_NameValueModelCopyWith<$Res> {
|
||||||
|
__$$_NameValueModelCopyWithImpl(
|
||||||
|
_$_NameValueModel _value, $Res Function(_$_NameValueModel) _then)
|
||||||
|
: super(_value, _then);
|
||||||
|
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
@override
|
||||||
|
$Res call({
|
||||||
|
Object? name = null,
|
||||||
|
Object? value = freezed,
|
||||||
|
}) {
|
||||||
|
return _then(_$_NameValueModel(
|
||||||
|
name: null == name
|
||||||
|
? _value.name
|
||||||
|
: name // ignore: cast_nullable_to_non_nullable
|
||||||
|
as String,
|
||||||
|
value: freezed == value
|
||||||
|
? _value.value
|
||||||
|
: value // ignore: cast_nullable_to_non_nullable
|
||||||
|
as dynamic,
|
||||||
|
));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// @nodoc
|
||||||
|
@JsonSerializable()
|
||||||
|
class _$_NameValueModel
|
||||||
|
with DiagnosticableTreeMixin
|
||||||
|
implements _NameValueModel {
|
||||||
|
const _$_NameValueModel({required this.name, required this.value});
|
||||||
|
|
||||||
|
factory _$_NameValueModel.fromJson(Map<String, dynamic> json) =>
|
||||||
|
_$$_NameValueModelFromJson(json);
|
||||||
|
|
||||||
|
@override
|
||||||
|
final String name;
|
||||||
|
@override
|
||||||
|
final dynamic value;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) {
|
||||||
|
return 'NameValueModel(name: $name, value: $value)';
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
void debugFillProperties(DiagnosticPropertiesBuilder properties) {
|
||||||
|
super.debugFillProperties(properties);
|
||||||
|
properties
|
||||||
|
..add(DiagnosticsProperty('type', 'NameValueModel'))
|
||||||
|
..add(DiagnosticsProperty('name', name))
|
||||||
|
..add(DiagnosticsProperty('value', value));
|
||||||
|
}
|
||||||
|
|
||||||
|
@override
|
||||||
|
bool operator ==(dynamic other) {
|
||||||
|
return identical(this, other) ||
|
||||||
|
(other.runtimeType == runtimeType &&
|
||||||
|
other is _$_NameValueModel &&
|
||||||
|
(identical(other.name, name) || other.name == name) &&
|
||||||
|
const DeepCollectionEquality().equals(other.value, value));
|
||||||
|
}
|
||||||
|
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
@override
|
||||||
|
int get hashCode => Object.hash(
|
||||||
|
runtimeType, name, const DeepCollectionEquality().hash(value));
|
||||||
|
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
@override
|
||||||
|
@pragma('vm:prefer-inline')
|
||||||
|
_$$_NameValueModelCopyWith<_$_NameValueModel> get copyWith =>
|
||||||
|
__$$_NameValueModelCopyWithImpl<_$_NameValueModel>(this, _$identity);
|
||||||
|
|
||||||
|
@override
|
||||||
|
Map<String, dynamic> toJson() {
|
||||||
|
return _$$_NameValueModelToJson(
|
||||||
|
this,
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
abstract class _NameValueModel implements NameValueModel {
|
||||||
|
const factory _NameValueModel(
|
||||||
|
{required final String name,
|
||||||
|
required final dynamic value}) = _$_NameValueModel;
|
||||||
|
|
||||||
|
factory _NameValueModel.fromJson(Map<String, dynamic> json) =
|
||||||
|
_$_NameValueModel.fromJson;
|
||||||
|
|
||||||
|
@override
|
||||||
|
String get name;
|
||||||
|
@override
|
||||||
|
dynamic get value;
|
||||||
|
@override
|
||||||
|
@JsonKey(ignore: true)
|
||||||
|
_$$_NameValueModelCopyWith<_$_NameValueModel> get copyWith =>
|
||||||
|
throw _privateConstructorUsedError;
|
||||||
|
}
|
19
lib/models/name_value_model.g.dart
Normal file
19
lib/models/name_value_model.g.dart
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
// GENERATED CODE - DO NOT MODIFY BY HAND
|
||||||
|
|
||||||
|
part of 'name_value_model.dart';
|
||||||
|
|
||||||
|
// **************************************************************************
|
||||||
|
// JsonSerializableGenerator
|
||||||
|
// **************************************************************************
|
||||||
|
|
||||||
|
_$_NameValueModel _$$_NameValueModelFromJson(Map<String, dynamic> json) =>
|
||||||
|
_$_NameValueModel(
|
||||||
|
name: json['name'] as String,
|
||||||
|
value: json['value'],
|
||||||
|
);
|
||||||
|
|
||||||
|
Map<String, dynamic> _$$_NameValueModelToJson(_$_NameValueModel instance) =>
|
||||||
|
<String, dynamic>{
|
||||||
|
'name': instance.name,
|
||||||
|
'value': instance.value,
|
||||||
|
};
|
@ -37,7 +37,9 @@ class EditRequestHeadersState extends ConsumerState<EditRequestHeaders> {
|
|||||||
final length = ref.watch(activeRequestModelProvider
|
final length = ref.watch(activeRequestModelProvider
|
||||||
.select((value) => value?.requestHeaders?.length));
|
.select((value) => value?.requestHeaders?.length));
|
||||||
var rH = ref.read(activeRequestModelProvider)?.requestHeaders;
|
var rH = ref.read(activeRequestModelProvider)?.requestHeaders;
|
||||||
rows = (rH == null || rH.isEmpty) ? [const NameValueModel("", "")] : rH;
|
rows = (rH == null || rH.isEmpty)
|
||||||
|
? [const NameValueModel(name: "", value: "")]
|
||||||
|
: rH;
|
||||||
|
|
||||||
DaviModel<NameValueModel> model = DaviModel<NameValueModel>(
|
DaviModel<NameValueModel> model = DaviModel<NameValueModel>(
|
||||||
rows: rows,
|
rows: rows,
|
||||||
@ -49,10 +51,10 @@ class EditRequestHeadersState extends ConsumerState<EditRequestHeaders> {
|
|||||||
int idx = row.index;
|
int idx = row.index;
|
||||||
return CellField(
|
return CellField(
|
||||||
keyId: "$activeId-$idx-headers-k-$seed",
|
keyId: "$activeId-$idx-headers-k-$seed",
|
||||||
initialValue: rows[idx].k,
|
initialValue: rows[idx].name,
|
||||||
hintText: "Add Header Name",
|
hintText: "Add Header Name",
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
rows[idx] = rows[idx].copyWith(k: value);
|
rows[idx] = rows[idx].copyWith(name: value);
|
||||||
_onFieldChange(activeId!);
|
_onFieldChange(activeId!);
|
||||||
},
|
},
|
||||||
colorScheme: Theme.of(context).colorScheme,
|
colorScheme: Theme.of(context).colorScheme,
|
||||||
@ -76,10 +78,10 @@ class EditRequestHeadersState extends ConsumerState<EditRequestHeaders> {
|
|||||||
int idx = row.index;
|
int idx = row.index;
|
||||||
return CellField(
|
return CellField(
|
||||||
keyId: "$activeId-$idx-headers-v-$seed",
|
keyId: "$activeId-$idx-headers-v-$seed",
|
||||||
initialValue: rows[idx].v,
|
initialValue: rows[idx].value,
|
||||||
hintText: " Add Header Value",
|
hintText: " Add Header Value",
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
rows[idx] = rows[idx].copyWith(v: value);
|
rows[idx] = rows[idx].copyWith(value: value);
|
||||||
_onFieldChange(activeId!);
|
_onFieldChange(activeId!);
|
||||||
},
|
},
|
||||||
colorScheme: Theme.of(context).colorScheme,
|
colorScheme: Theme.of(context).colorScheme,
|
||||||
@ -133,7 +135,7 @@ class EditRequestHeadersState extends ConsumerState<EditRequestHeaders> {
|
|||||||
padding: const EdgeInsets.only(bottom: 30),
|
padding: const EdgeInsets.only(bottom: 30),
|
||||||
child: ElevatedButton.icon(
|
child: ElevatedButton.icon(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
rows.add(const NameValueModel("", ""));
|
rows.add(const NameValueModel(name: "", value: ""));
|
||||||
_onFieldChange(activeId!);
|
_onFieldChange(activeId!);
|
||||||
},
|
},
|
||||||
icon: const Icon(Icons.add),
|
icon: const Icon(Icons.add),
|
||||||
|
@ -38,7 +38,9 @@ class EditRequestURLParamsState extends ConsumerState<EditRequestURLParams> {
|
|||||||
final length = ref.watch(activeRequestModelProvider
|
final length = ref.watch(activeRequestModelProvider
|
||||||
.select((value) => value?.requestParams?.length));
|
.select((value) => value?.requestParams?.length));
|
||||||
var rP = ref.read(activeRequestModelProvider)?.requestParams;
|
var rP = ref.read(activeRequestModelProvider)?.requestParams;
|
||||||
rows = (rP == null || rP.isEmpty) ? [const NameValueModel("", "")] : rP;
|
rows = (rP == null || rP.isEmpty)
|
||||||
|
? [const NameValueModel(name: "", value: "")]
|
||||||
|
: rP;
|
||||||
|
|
||||||
DaviModel<NameValueModel> model = DaviModel<NameValueModel>(
|
DaviModel<NameValueModel> model = DaviModel<NameValueModel>(
|
||||||
rows: rows,
|
rows: rows,
|
||||||
@ -50,10 +52,10 @@ class EditRequestURLParamsState extends ConsumerState<EditRequestURLParams> {
|
|||||||
int idx = row.index;
|
int idx = row.index;
|
||||||
return CellField(
|
return CellField(
|
||||||
keyId: "$activeId-$idx-params-k-$seed",
|
keyId: "$activeId-$idx-params-k-$seed",
|
||||||
initialValue: rows[idx].k,
|
initialValue: rows[idx].name,
|
||||||
hintText: "Add URL Parameter",
|
hintText: "Add URL Parameter",
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
rows[idx] = rows[idx].copyWith(k: value);
|
rows[idx] = rows[idx].copyWith(name: value);
|
||||||
_onFieldChange(activeId!);
|
_onFieldChange(activeId!);
|
||||||
},
|
},
|
||||||
colorScheme: Theme.of(context).colorScheme,
|
colorScheme: Theme.of(context).colorScheme,
|
||||||
@ -77,10 +79,10 @@ class EditRequestURLParamsState extends ConsumerState<EditRequestURLParams> {
|
|||||||
int idx = row.index;
|
int idx = row.index;
|
||||||
return CellField(
|
return CellField(
|
||||||
keyId: "$activeId-$idx-params-v-$seed",
|
keyId: "$activeId-$idx-params-v-$seed",
|
||||||
initialValue: rows[idx].v,
|
initialValue: rows[idx].value,
|
||||||
hintText: "Add Value",
|
hintText: "Add Value",
|
||||||
onChanged: (value) {
|
onChanged: (value) {
|
||||||
rows[idx] = rows[idx].copyWith(v: value);
|
rows[idx] = rows[idx].copyWith(value: value);
|
||||||
_onFieldChange(activeId!);
|
_onFieldChange(activeId!);
|
||||||
},
|
},
|
||||||
colorScheme: Theme.of(context).colorScheme,
|
colorScheme: Theme.of(context).colorScheme,
|
||||||
@ -134,7 +136,7 @@ class EditRequestURLParamsState extends ConsumerState<EditRequestURLParams> {
|
|||||||
padding: const EdgeInsets.only(bottom: 30),
|
padding: const EdgeInsets.only(bottom: 30),
|
||||||
child: ElevatedButton.icon(
|
child: ElevatedButton.icon(
|
||||||
onPressed: () {
|
onPressed: () {
|
||||||
rows.add(const NameValueModel("", ""));
|
rows.add(const NameValueModel(name: "", value: ""));
|
||||||
_onFieldChange(activeId!);
|
_onFieldChange(activeId!);
|
||||||
},
|
},
|
||||||
icon: const Icon(Icons.add),
|
icon: const Icon(Icons.add),
|
||||||
|
@ -67,12 +67,12 @@ Map<String, String>? rowsToMap(List<NameValueModel>? kvRows,
|
|||||||
}
|
}
|
||||||
Map<String, String> finalMap = {};
|
Map<String, String> finalMap = {};
|
||||||
for (var row in kvRows) {
|
for (var row in kvRows) {
|
||||||
if (row.k.trim() != "") {
|
if (row.name.trim() != "") {
|
||||||
String key = row.k;
|
String key = row.name;
|
||||||
if (isHeader) {
|
if (isHeader) {
|
||||||
key = key.toLowerCase();
|
key = key.toLowerCase();
|
||||||
}
|
}
|
||||||
finalMap[key] = row.v.toString();
|
finalMap[key] = row.value.toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return finalMap;
|
return finalMap;
|
||||||
@ -84,7 +84,7 @@ List<NameValueModel>? mapToRows(Map<String, String>? kvMap) {
|
|||||||
}
|
}
|
||||||
List<NameValueModel> finalRows = [];
|
List<NameValueModel> finalRows = [];
|
||||||
for (var k in kvMap.keys) {
|
for (var k in kvMap.keys) {
|
||||||
finalRows.add(NameValueModel(k, kvMap[k]));
|
finalRows.add(NameValueModel(name: k, value: kvMap[k]));
|
||||||
}
|
}
|
||||||
return finalRows;
|
return finalRows;
|
||||||
}
|
}
|
||||||
|
102
pubspec.lock
102
pubspec.lock
@ -81,6 +81,54 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.1"
|
version: "1.1.1"
|
||||||
|
build_daemon:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: build_daemon
|
||||||
|
sha256: "5f02d73eb2ba16483e693f80bee4f088563a820e47d1027d4cdfe62b5bb43e65"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "4.0.0"
|
||||||
|
build_resolvers:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: build_resolvers
|
||||||
|
sha256: "6c4dd11d05d056e76320b828a1db0fc01ccd376922526f8e9d6c796a5adbac20"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.2.1"
|
||||||
|
build_runner:
|
||||||
|
dependency: "direct dev"
|
||||||
|
description:
|
||||||
|
name: build_runner
|
||||||
|
sha256: "10c6bcdbf9d049a0b666702cf1cee4ddfdc38f02a19d35ae392863b47519848b"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.4.6"
|
||||||
|
build_runner_core:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: build_runner_core
|
||||||
|
sha256: "6d6ee4276b1c5f34f21fdf39425202712d2be82019983d52f351c94aafbc2c41"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "7.2.10"
|
||||||
|
built_collection:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: built_collection
|
||||||
|
sha256: "376e3dd27b51ea877c28d525560790aee2e6fbb5f20e2f85d5081027d94e2100"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "5.1.1"
|
||||||
|
built_value:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: built_value
|
||||||
|
sha256: ff627b645b28fb8bdb69e645f910c2458fd6b65f6585c3a53e0626024897dedf
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "8.6.2"
|
||||||
characters:
|
characters:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -113,6 +161,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.1.1"
|
version: "1.1.1"
|
||||||
|
code_builder:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: code_builder
|
||||||
|
sha256: "4ad01d6e56db961d29661561effde45e519939fdaeb46c351275b182eac70189"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "4.5.0"
|
||||||
collection:
|
collection:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -193,6 +249,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "7.0.0"
|
version: "7.0.0"
|
||||||
|
fixnum:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: fixnum
|
||||||
|
sha256: "25517a4deb0c03aa0f32fd12db525856438902d9c16536311e76cdc57b31d7d1"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.1.0"
|
||||||
flutter:
|
flutter:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description: flutter
|
description: flutter
|
||||||
@ -240,8 +304,16 @@ packages:
|
|||||||
description: flutter
|
description: flutter
|
||||||
source: sdk
|
source: sdk
|
||||||
version: "0.0.0"
|
version: "0.0.0"
|
||||||
|
freezed:
|
||||||
|
dependency: "direct dev"
|
||||||
|
description:
|
||||||
|
name: freezed
|
||||||
|
sha256: "2df89855fe181baae3b6d714dc3c4317acf4fccd495a6f36e5e00f24144c6c3b"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.4.1"
|
||||||
freezed_annotation:
|
freezed_annotation:
|
||||||
dependency: transitive
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: freezed_annotation
|
name: freezed_annotation
|
||||||
sha256: c3fd9336eb55a38cc1bbd79ab17573113a8deccd0ecbbf926cca3c62803b5c2d
|
sha256: c3fd9336eb55a38cc1bbd79ab17573113a8deccd0ecbbf926cca3c62803b5c2d
|
||||||
@ -272,6 +344,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "5.1.0"
|
version: "5.1.0"
|
||||||
|
graphs:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: graphs
|
||||||
|
sha256: aedc5a15e78fc65a6e23bcd927f24c64dd995062bcd1ca6eda65a3cff92a4d19
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.3.1"
|
||||||
highlighter:
|
highlighter:
|
||||||
dependency: "direct main"
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
@ -361,7 +441,7 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "0.6.7"
|
version: "0.6.7"
|
||||||
json_annotation:
|
json_annotation:
|
||||||
dependency: transitive
|
dependency: "direct main"
|
||||||
description:
|
description:
|
||||||
name: json_annotation
|
name: json_annotation
|
||||||
sha256: b10a7b2ff83d83c777edba3c6a0f97045ddadd56c944e1a23a3fdf43a1bf4467
|
sha256: b10a7b2ff83d83c777edba3c6a0f97045ddadd56c944e1a23a3fdf43a1bf4467
|
||||||
@ -369,7 +449,7 @@ packages:
|
|||||||
source: hosted
|
source: hosted
|
||||||
version: "4.8.1"
|
version: "4.8.1"
|
||||||
json_serializable:
|
json_serializable:
|
||||||
dependency: transitive
|
dependency: "direct dev"
|
||||||
description:
|
description:
|
||||||
name: json_serializable
|
name: json_serializable
|
||||||
sha256: aa1f5a8912615733e0fdc7a02af03308933c93235bdc8d50d0b0c8a8ccb0b969
|
sha256: aa1f5a8912615733e0fdc7a02af03308933c93235bdc8d50d0b0c8a8ccb0b969
|
||||||
@ -757,6 +837,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "2.1.1"
|
version: "2.1.1"
|
||||||
|
stream_transform:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: stream_transform
|
||||||
|
sha256: "14a00e794c7c11aa145a170587321aedce29769c08d7f58b1d141da75e3b1c6f"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "2.1.0"
|
||||||
string_scanner:
|
string_scanner:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
@ -805,6 +893,14 @@ packages:
|
|||||||
url: "https://pub.dev"
|
url: "https://pub.dev"
|
||||||
source: hosted
|
source: hosted
|
||||||
version: "1.2.0"
|
version: "1.2.0"
|
||||||
|
timing:
|
||||||
|
dependency: transitive
|
||||||
|
description:
|
||||||
|
name: timing
|
||||||
|
sha256: "70a3b636575d4163c477e6de42f247a23b315ae20e86442bebe32d3cabf61c32"
|
||||||
|
url: "https://pub.dev"
|
||||||
|
source: hosted
|
||||||
|
version: "1.0.1"
|
||||||
typed_data:
|
typed_data:
|
||||||
dependency: transitive
|
dependency: transitive
|
||||||
description:
|
description:
|
||||||
|
@ -37,6 +37,8 @@ dependencies:
|
|||||||
just_audio: ^0.9.34
|
just_audio: ^0.9.34
|
||||||
just_audio_mpv: ^0.1.7
|
just_audio_mpv: ^0.1.7
|
||||||
just_audio_windows: ^0.2.0
|
just_audio_windows: ^0.2.0
|
||||||
|
freezed_annotation: ^2.4.1
|
||||||
|
json_annotation: ^4.8.1
|
||||||
|
|
||||||
dev_dependencies:
|
dev_dependencies:
|
||||||
flutter_test:
|
flutter_test:
|
||||||
@ -44,6 +46,9 @@ dev_dependencies:
|
|||||||
flutter_lints: ^2.0.2
|
flutter_lints: ^2.0.2
|
||||||
flutter_launcher_icons: ^0.13.1
|
flutter_launcher_icons: ^0.13.1
|
||||||
test: ^1.24.3
|
test: ^1.24.3
|
||||||
|
build_runner: ^2.4.6
|
||||||
|
freezed: ^2.4.1
|
||||||
|
json_serializable: ^6.7.1
|
||||||
|
|
||||||
flutter:
|
flutter:
|
||||||
uses-material-design: true
|
uses-material-design: true
|
||||||
|
@ -2,16 +2,16 @@ import 'package:test/test.dart';
|
|||||||
import 'package:apidash/models/name_value_model.dart';
|
import 'package:apidash/models/name_value_model.dart';
|
||||||
|
|
||||||
void main() {
|
void main() {
|
||||||
const kvRow1 = NameValueModel("harry", 23);
|
const kvRow1 = NameValueModel(name: "harry", value: 23);
|
||||||
String kvRow1Expected = "{harry: 23}";
|
String kvRow1Expected = "{harry: 23}";
|
||||||
|
|
||||||
test('Testing toString()', () {
|
test('Testing toString()', () {
|
||||||
expect(kvRow1.toString(), kvRow1Expected);
|
expect(kvRow1.toString(), kvRow1Expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
const kvRow2Expected = NameValueModel("winter", "26");
|
const kvRow2Expected = NameValueModel(name: "winter", value: "26");
|
||||||
test('Testing copyWith()', () {
|
test('Testing copyWith()', () {
|
||||||
expect(kvRow1.copyWith(k: "winter", v: "26"), kvRow2Expected);
|
expect(kvRow1.copyWith(name: "winter", value: "26"), kvRow2Expected);
|
||||||
});
|
});
|
||||||
|
|
||||||
test('Testing hashcode', () {
|
test('Testing hashcode', () {
|
||||||
|
@ -55,8 +55,9 @@ void main() {
|
|||||||
url: 'api.foss42.com/case/lower',
|
url: 'api.foss42.com/case/lower',
|
||||||
name: 'foss42 api',
|
name: 'foss42 api',
|
||||||
requestHeaders: const [
|
requestHeaders: const [
|
||||||
NameValueModel('content-length', '18'),
|
NameValueModel(name: 'content-length', value: '18'),
|
||||||
NameValueModel('content-type', 'application/json; charset=utf-8')
|
NameValueModel(
|
||||||
|
name: 'content-type', value: 'application/json; charset=utf-8')
|
||||||
],
|
],
|
||||||
requestBodyContentType: ContentType.json,
|
requestBodyContentType: ContentType.json,
|
||||||
requestBody: '''{
|
requestBody: '''{
|
||||||
@ -71,8 +72,9 @@ void main() {
|
|||||||
url: 'api.foss42.com/case/lower',
|
url: 'api.foss42.com/case/lower',
|
||||||
name: 'foss42 api',
|
name: 'foss42 api',
|
||||||
requestHeaders: [
|
requestHeaders: [
|
||||||
NameValueModel('content-length', '18'),
|
NameValueModel(name: 'content-length', value: '18'),
|
||||||
NameValueModel('content-type', 'application/json; charset=utf-8')
|
NameValueModel(
|
||||||
|
name: 'content-type', value: 'application/json; charset=utf-8')
|
||||||
],
|
],
|
||||||
requestBodyContentType: ContentType.json,
|
requestBodyContentType: ContentType.json,
|
||||||
requestBody: '''{
|
requestBody: '''{
|
||||||
|
@ -14,7 +14,7 @@ const requestModelGet2 = RequestModel(
|
|||||||
url: 'https://api.foss42.com/country/data',
|
url: 'https://api.foss42.com/country/data',
|
||||||
method: HTTPVerb.get,
|
method: HTTPVerb.get,
|
||||||
requestParams: [
|
requestParams: [
|
||||||
NameValueModel('code', 'US'),
|
NameValueModel(name: 'code', value: 'US'),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -24,7 +24,7 @@ const requestModelGet3 = RequestModel(
|
|||||||
url: 'https://api.foss42.com/country/data?code=US',
|
url: 'https://api.foss42.com/country/data?code=US',
|
||||||
method: HTTPVerb.get,
|
method: HTTPVerb.get,
|
||||||
requestParams: [
|
requestParams: [
|
||||||
NameValueModel('code', 'IND'),
|
NameValueModel(name: 'code', value: 'IND'),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -34,11 +34,11 @@ const requestModelGet4 = RequestModel(
|
|||||||
url: 'https://api.foss42.com/humanize/social',
|
url: 'https://api.foss42.com/humanize/social',
|
||||||
method: HTTPVerb.get,
|
method: HTTPVerb.get,
|
||||||
requestParams: [
|
requestParams: [
|
||||||
NameValueModel('num', '8700000'),
|
NameValueModel(name: 'num', value: '8700000'),
|
||||||
NameValueModel('digits', '3'),
|
NameValueModel(name: 'digits', value: '3'),
|
||||||
NameValueModel('system', 'SS'),
|
NameValueModel(name: 'system', value: 'SS'),
|
||||||
NameValueModel('add_space', 'true'),
|
NameValueModel(name: 'add_space', value: 'true'),
|
||||||
NameValueModel('trailing_zeros', 'true'),
|
NameValueModel(name: 'trailing_zeros', value: 'true'),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -48,7 +48,7 @@ const requestModelGet5 = RequestModel(
|
|||||||
url: 'https://api.github.com/repos/foss42/apidash',
|
url: 'https://api.github.com/repos/foss42/apidash',
|
||||||
method: HTTPVerb.get,
|
method: HTTPVerb.get,
|
||||||
requestHeaders: [
|
requestHeaders: [
|
||||||
NameValueModel('Authorization', 'Bearer XYZ'),
|
NameValueModel(name: 'Authorization', value: 'Bearer XYZ'),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
@ -58,10 +58,10 @@ const requestModelGet6 = RequestModel(
|
|||||||
url: 'https://api.foss42.com/humanize/social',
|
url: 'https://api.foss42.com/humanize/social',
|
||||||
method: HTTPVerb.get,
|
method: HTTPVerb.get,
|
||||||
requestHeaders: [
|
requestHeaders: [
|
||||||
NameValueModel('Authorization', 'Bearer XYZ'),
|
NameValueModel(name: 'Authorization', value: 'Bearer XYZ'),
|
||||||
],
|
],
|
||||||
requestParams: [
|
requestParams: [
|
||||||
NameValueModel('raw', 'true'),
|
NameValueModel(name: 'raw', value: 'true'),
|
||||||
],
|
],
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -73,18 +73,18 @@ void main() {
|
|||||||
expect(rowsToMap(null), null);
|
expect(rowsToMap(null), null);
|
||||||
});
|
});
|
||||||
test('Testing for string KVRow values', () {
|
test('Testing for string KVRow values', () {
|
||||||
const kvRow1 = NameValueModel("code", "IN");
|
const kvRow1 = NameValueModel(name: "code", value: "IN");
|
||||||
expect(rowsToMap([kvRow1]), {"code": "IN"});
|
expect(rowsToMap([kvRow1]), {"code": "IN"});
|
||||||
});
|
});
|
||||||
test('Testing when header is True', () {
|
test('Testing when header is True', () {
|
||||||
const kvRow2 = NameValueModel("Text", "ABC");
|
const kvRow2 = NameValueModel(name: "Text", value: "ABC");
|
||||||
expect(rowsToMap([kvRow2], isHeader: true), {"text": "ABC"});
|
expect(rowsToMap([kvRow2], isHeader: true), {"text": "ABC"});
|
||||||
});
|
});
|
||||||
test('Testing when header is false and key is in upper case', () {
|
test('Testing when header is false and key is in upper case', () {
|
||||||
const kvRow3 = <NameValueModel>[
|
const kvRow3 = <NameValueModel>[
|
||||||
NameValueModel("TEXT", "ABC"),
|
NameValueModel(name: "TEXT", value: "ABC"),
|
||||||
NameValueModel("version", 0.1),
|
NameValueModel(name: "version", value: 0.1),
|
||||||
NameValueModel("month", 4),
|
NameValueModel(name: "month", value: 4),
|
||||||
];
|
];
|
||||||
expect(
|
expect(
|
||||||
rowsToMap(kvRow3), {"TEXT": "ABC", "version": "0.1", "month": "4"});
|
rowsToMap(kvRow3), {"TEXT": "ABC", "version": "0.1", "month": "4"});
|
||||||
@ -98,9 +98,9 @@ void main() {
|
|||||||
test('Testing with a map value', () {
|
test('Testing with a map value', () {
|
||||||
Map<String, String> value1 = {"text": "abc", "lang": "eng", "code": "1"};
|
Map<String, String> value1 = {"text": "abc", "lang": "eng", "code": "1"};
|
||||||
const result1Expected = <NameValueModel>[
|
const result1Expected = <NameValueModel>[
|
||||||
NameValueModel("text", "abc"),
|
NameValueModel(name: "text", value: "abc"),
|
||||||
NameValueModel("lang", "eng"),
|
NameValueModel(name: "lang", value: "eng"),
|
||||||
NameValueModel("code", "1")
|
NameValueModel(name: "code", value: "1")
|
||||||
];
|
];
|
||||||
expect(mapToRows(value1), result1Expected);
|
expect(mapToRows(value1), result1Expected);
|
||||||
});
|
});
|
||||||
|
@ -176,7 +176,7 @@ void main() {
|
|||||||
group("Testing getValidRequestUri", () {
|
group("Testing getValidRequestUri", () {
|
||||||
test('Testing getValidRequestUri for normal values', () {
|
test('Testing getValidRequestUri for normal values', () {
|
||||||
String url1 = "https://api.foss42.com/country/data";
|
String url1 = "https://api.foss42.com/country/data";
|
||||||
const kvRow1 = NameValueModel("code", "US");
|
const kvRow1 = NameValueModel(name: "code", value: "US");
|
||||||
Uri uri1Expected = Uri(
|
Uri uri1Expected = Uri(
|
||||||
scheme: 'https',
|
scheme: 'https',
|
||||||
host: 'api.foss42.com',
|
host: 'api.foss42.com',
|
||||||
@ -185,16 +185,16 @@ void main() {
|
|||||||
expect(getValidRequestUri(url1, [kvRow1]), (uri1Expected, null));
|
expect(getValidRequestUri(url1, [kvRow1]), (uri1Expected, null));
|
||||||
});
|
});
|
||||||
test('Testing getValidRequestUri for null url value', () {
|
test('Testing getValidRequestUri for null url value', () {
|
||||||
const kvRow2 = NameValueModel("code", "US");
|
const kvRow2 = NameValueModel(name: "code", value: "US");
|
||||||
expect(getValidRequestUri(null, [kvRow2]), (null, "URL is missing!"));
|
expect(getValidRequestUri(null, [kvRow2]), (null, "URL is missing!"));
|
||||||
});
|
});
|
||||||
test('Testing getValidRequestUri for empty url value', () {
|
test('Testing getValidRequestUri for empty url value', () {
|
||||||
const kvRow3 = NameValueModel("", "");
|
const kvRow3 = NameValueModel(name: "", value: "");
|
||||||
expect(getValidRequestUri("", [kvRow3]), (null, "URL is missing!"));
|
expect(getValidRequestUri("", [kvRow3]), (null, "URL is missing!"));
|
||||||
});
|
});
|
||||||
test('Testing getValidRequestUri when https is not provided in url', () {
|
test('Testing getValidRequestUri when https is not provided in url', () {
|
||||||
String url4 = "api.foss42.com/country/data";
|
String url4 = "api.foss42.com/country/data";
|
||||||
const kvRow4 = NameValueModel("code", "US");
|
const kvRow4 = NameValueModel(name: "code", value: "US");
|
||||||
Uri uri4Expected = Uri(
|
Uri uri4Expected = Uri(
|
||||||
scheme: 'https',
|
scheme: 'https',
|
||||||
host: 'api.foss42.com',
|
host: 'api.foss42.com',
|
||||||
@ -218,7 +218,7 @@ void main() {
|
|||||||
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";
|
String url6 = "api.foss42.com/country/data?code=IND";
|
||||||
const kvRow6 = NameValueModel("code", "US");
|
const kvRow6 = NameValueModel(name: "code", value: "US");
|
||||||
Uri uri6Expected = Uri(
|
Uri uri6Expected = Uri(
|
||||||
scheme: 'https',
|
scheme: 'https',
|
||||||
host: 'api.foss42.com',
|
host: 'api.foss42.com',
|
||||||
|
@ -204,8 +204,9 @@ void main() {
|
|||||||
url: 'api.foss42.com/case/lower',
|
url: 'api.foss42.com/case/lower',
|
||||||
name: 'foss42 api',
|
name: 'foss42 api',
|
||||||
requestHeaders: [
|
requestHeaders: [
|
||||||
NameValueModel('content-length', '18'),
|
NameValueModel(name: 'content-length', value: '18'),
|
||||||
NameValueModel('content-type', 'application/json; charset=utf-8')
|
NameValueModel(
|
||||||
|
name: 'content-type', value: 'application/json; charset=utf-8')
|
||||||
],
|
],
|
||||||
requestBodyContentType: ContentType.json,
|
requestBodyContentType: ContentType.json,
|
||||||
requestBody: '''{
|
requestBody: '''{
|
||||||
|
Reference in New Issue
Block a user