diff --git a/lib/codegen/kotlin/pkg_okhttp.dart b/lib/codegen/kotlin/pkg_okhttp.dart index 260b00d2..5bb90524 100644 --- a/lib/codegen/kotlin/pkg_okhttp.dart +++ b/lib/codegen/kotlin/pkg_okhttp.dart @@ -47,7 +47,7 @@ val body = "${requestModel.requestBody}".toRequestBody(mediaType)\n"""; } for (final queryParam in requestModel.requestParams!) { result = - """$result .addQueryParameter("${queryParam.k}", "${queryParam.v}")\n"""; + """$result .addQueryParameter("${queryParam.name}", "${queryParam.value}")\n"""; } return result; } @@ -58,7 +58,7 @@ val body = "${requestModel.requestBody}".toRequestBody(mediaType)\n"""; return result; } for (final header in requestModel.requestHeaders!) { - result = """$result .addHeader("${header.k}", "${header.v}")\n"""; + result = """$result .addHeader("${header.name}", "${header.value}")\n"""; } return result; } diff --git a/lib/models/name_value_model.dart b/lib/models/name_value_model.dart index 5fa65b97..43a0bd8c 100644 --- a/lib/models/name_value_model.dart +++ b/lib/models/name_value_model.dart @@ -1,38 +1,17 @@ -import 'package:flutter/material.dart'; +import 'package:freezed_annotation/freezed_annotation.dart'; +import 'package:flutter/foundation.dart'; -@immutable -class NameValueModel { - const NameValueModel(this.k, this.v); +part 'name_value_model.freezed.dart'; - final String k; - final dynamic v; +part 'name_value_model.g.dart'; - NameValueModel copyWith({ - String? k, - dynamic v, - }) { - return NameValueModel(k ?? this.k, v ?? this.v); - } +@freezed +class NameValueModel with _$NameValueModel { + const factory NameValueModel({ + required String name, + required dynamic value, + }) = _NameValueModel; - @override - String toString() { - 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, - ); - } + factory NameValueModel.fromJson(Map json) => + _$NameValueModelFromJson(json); } diff --git a/lib/models/name_value_model.freezed.dart b/lib/models/name_value_model.freezed.dart new file mode 100644 index 00000000..e7d9e8e0 --- /dev/null +++ b/lib/models/name_value_model.freezed.dart @@ -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 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 json) { + return _NameValueModel.fromJson(json); +} + +/// @nodoc +mixin _$NameValueModel { + String get name => throw _privateConstructorUsedError; + dynamic get value => throw _privateConstructorUsedError; + + Map toJson() => throw _privateConstructorUsedError; + @JsonKey(ignore: true) + $NameValueModelCopyWith 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 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 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 json) = + _$_NameValueModel.fromJson; + + @override + String get name; + @override + dynamic get value; + @override + @JsonKey(ignore: true) + _$$_NameValueModelCopyWith<_$_NameValueModel> get copyWith => + throw _privateConstructorUsedError; +} diff --git a/lib/models/name_value_model.g.dart b/lib/models/name_value_model.g.dart new file mode 100644 index 00000000..25867df8 --- /dev/null +++ b/lib/models/name_value_model.g.dart @@ -0,0 +1,19 @@ +// GENERATED CODE - DO NOT MODIFY BY HAND + +part of 'name_value_model.dart'; + +// ************************************************************************** +// JsonSerializableGenerator +// ************************************************************************** + +_$_NameValueModel _$$_NameValueModelFromJson(Map json) => + _$_NameValueModel( + name: json['name'] as String, + value: json['value'], + ); + +Map _$$_NameValueModelToJson(_$_NameValueModel instance) => + { + 'name': instance.name, + 'value': instance.value, + }; 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 33fe2a3e..d1b8f5de 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 @@ -37,7 +37,9 @@ class EditRequestHeadersState extends ConsumerState { final length = ref.watch(activeRequestModelProvider .select((value) => value?.requestHeaders?.length)); 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 model = DaviModel( rows: rows, @@ -49,10 +51,10 @@ class EditRequestHeadersState extends ConsumerState { int idx = row.index; return CellField( keyId: "$activeId-$idx-headers-k-$seed", - initialValue: rows[idx].k, + initialValue: rows[idx].name, hintText: "Add Header Name", onChanged: (value) { - rows[idx] = rows[idx].copyWith(k: value); + rows[idx] = rows[idx].copyWith(name: value); _onFieldChange(activeId!); }, colorScheme: Theme.of(context).colorScheme, @@ -76,10 +78,10 @@ class EditRequestHeadersState extends ConsumerState { int idx = row.index; return CellField( keyId: "$activeId-$idx-headers-v-$seed", - initialValue: rows[idx].v, + initialValue: rows[idx].value, hintText: " Add Header Value", onChanged: (value) { - rows[idx] = rows[idx].copyWith(v: value); + rows[idx] = rows[idx].copyWith(value: value); _onFieldChange(activeId!); }, colorScheme: Theme.of(context).colorScheme, @@ -133,7 +135,7 @@ class EditRequestHeadersState extends ConsumerState { padding: const EdgeInsets.only(bottom: 30), child: ElevatedButton.icon( onPressed: () { - rows.add(const NameValueModel("", "")); + rows.add(const NameValueModel(name: "", value: "")); _onFieldChange(activeId!); }, icon: const Icon(Icons.add), diff --git a/lib/screens/home_page/editor_pane/details_card/request_pane/request_params.dart b/lib/screens/home_page/editor_pane/details_card/request_pane/request_params.dart index 3ddbcca6..e9c6d2cb 100644 --- a/lib/screens/home_page/editor_pane/details_card/request_pane/request_params.dart +++ b/lib/screens/home_page/editor_pane/details_card/request_pane/request_params.dart @@ -38,7 +38,9 @@ class EditRequestURLParamsState extends ConsumerState { final length = ref.watch(activeRequestModelProvider .select((value) => value?.requestParams?.length)); 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 model = DaviModel( rows: rows, @@ -50,10 +52,10 @@ class EditRequestURLParamsState extends ConsumerState { int idx = row.index; return CellField( keyId: "$activeId-$idx-params-k-$seed", - initialValue: rows[idx].k, + initialValue: rows[idx].name, hintText: "Add URL Parameter", onChanged: (value) { - rows[idx] = rows[idx].copyWith(k: value); + rows[idx] = rows[idx].copyWith(name: value); _onFieldChange(activeId!); }, colorScheme: Theme.of(context).colorScheme, @@ -77,10 +79,10 @@ class EditRequestURLParamsState extends ConsumerState { int idx = row.index; return CellField( keyId: "$activeId-$idx-params-v-$seed", - initialValue: rows[idx].v, + initialValue: rows[idx].value, hintText: "Add Value", onChanged: (value) { - rows[idx] = rows[idx].copyWith(v: value); + rows[idx] = rows[idx].copyWith(value: value); _onFieldChange(activeId!); }, colorScheme: Theme.of(context).colorScheme, @@ -134,7 +136,7 @@ class EditRequestURLParamsState extends ConsumerState { padding: const EdgeInsets.only(bottom: 30), child: ElevatedButton.icon( onPressed: () { - rows.add(const NameValueModel("", "")); + rows.add(const NameValueModel(name: "", value: "")); _onFieldChange(activeId!); }, icon: const Icon(Icons.add), diff --git a/lib/utils/convert_utils.dart b/lib/utils/convert_utils.dart index cf3f2327..379fff41 100644 --- a/lib/utils/convert_utils.dart +++ b/lib/utils/convert_utils.dart @@ -67,12 +67,12 @@ Map? rowsToMap(List? kvRows, } Map finalMap = {}; for (var row in kvRows) { - if (row.k.trim() != "") { - String key = row.k; + if (row.name.trim() != "") { + String key = row.name; if (isHeader) { key = key.toLowerCase(); } - finalMap[key] = row.v.toString(); + finalMap[key] = row.value.toString(); } } return finalMap; @@ -84,7 +84,7 @@ List? mapToRows(Map? kvMap) { } List finalRows = []; for (var k in kvMap.keys) { - finalRows.add(NameValueModel(k, kvMap[k])); + finalRows.add(NameValueModel(name: k, value: kvMap[k])); } return finalRows; } diff --git a/pubspec.lock b/pubspec.lock index f79df66a..f6146ef3 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -81,6 +81,54 @@ packages: url: "https://pub.dev" source: hosted 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: dependency: transitive description: @@ -113,6 +161,14 @@ packages: url: "https://pub.dev" source: hosted 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: dependency: "direct main" description: @@ -193,6 +249,14 @@ packages: url: "https://pub.dev" source: hosted version: "7.0.0" + fixnum: + dependency: transitive + description: + name: fixnum + sha256: "25517a4deb0c03aa0f32fd12db525856438902d9c16536311e76cdc57b31d7d1" + url: "https://pub.dev" + source: hosted + version: "1.1.0" flutter: dependency: "direct main" description: flutter @@ -240,8 +304,16 @@ packages: description: flutter source: sdk 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: - dependency: transitive + dependency: "direct main" description: name: freezed_annotation sha256: c3fd9336eb55a38cc1bbd79ab17573113a8deccd0ecbbf926cca3c62803b5c2d @@ -272,6 +344,14 @@ packages: url: "https://pub.dev" source: hosted version: "5.1.0" + graphs: + dependency: transitive + description: + name: graphs + sha256: aedc5a15e78fc65a6e23bcd927f24c64dd995062bcd1ca6eda65a3cff92a4d19 + url: "https://pub.dev" + source: hosted + version: "2.3.1" highlighter: dependency: "direct main" description: @@ -361,7 +441,7 @@ packages: source: hosted version: "0.6.7" json_annotation: - dependency: transitive + dependency: "direct main" description: name: json_annotation sha256: b10a7b2ff83d83c777edba3c6a0f97045ddadd56c944e1a23a3fdf43a1bf4467 @@ -369,7 +449,7 @@ packages: source: hosted version: "4.8.1" json_serializable: - dependency: transitive + dependency: "direct dev" description: name: json_serializable sha256: aa1f5a8912615733e0fdc7a02af03308933c93235bdc8d50d0b0c8a8ccb0b969 @@ -757,6 +837,14 @@ packages: url: "https://pub.dev" source: hosted 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: dependency: transitive description: @@ -805,6 +893,14 @@ packages: url: "https://pub.dev" source: hosted version: "1.2.0" + timing: + dependency: transitive + description: + name: timing + sha256: "70a3b636575d4163c477e6de42f247a23b315ae20e86442bebe32d3cabf61c32" + url: "https://pub.dev" + source: hosted + version: "1.0.1" typed_data: dependency: transitive description: diff --git a/pubspec.yaml b/pubspec.yaml index d00151e2..8f10a90f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -37,6 +37,8 @@ dependencies: just_audio: ^0.9.34 just_audio_mpv: ^0.1.7 just_audio_windows: ^0.2.0 + freezed_annotation: ^2.4.1 + json_annotation: ^4.8.1 dev_dependencies: flutter_test: @@ -44,6 +46,9 @@ dev_dependencies: flutter_lints: ^2.0.2 flutter_launcher_icons: ^0.13.1 test: ^1.24.3 + build_runner: ^2.4.6 + freezed: ^2.4.1 + json_serializable: ^6.7.1 flutter: uses-material-design: true diff --git a/test/models/kvrow_model_test.dart b/test/models/kvrow_model_test.dart index 8cdbe8ca..44093da5 100644 --- a/test/models/kvrow_model_test.dart +++ b/test/models/kvrow_model_test.dart @@ -2,16 +2,16 @@ import 'package:test/test.dart'; import 'package:apidash/models/name_value_model.dart'; void main() { - const kvRow1 = NameValueModel("harry", 23); + const kvRow1 = NameValueModel(name: "harry", value: 23); String kvRow1Expected = "{harry: 23}"; test('Testing toString()', () { expect(kvRow1.toString(), kvRow1Expected); }); - const kvRow2Expected = NameValueModel("winter", "26"); + const kvRow2Expected = NameValueModel(name: "winter", value: "26"); test('Testing copyWith()', () { - expect(kvRow1.copyWith(k: "winter", v: "26"), kvRow2Expected); + expect(kvRow1.copyWith(name: "winter", value: "26"), kvRow2Expected); }); test('Testing hashcode', () { diff --git a/test/models/request_model_test.dart b/test/models/request_model_test.dart index aca396e8..4d08da65 100644 --- a/test/models/request_model_test.dart +++ b/test/models/request_model_test.dart @@ -55,8 +55,9 @@ void main() { url: 'api.foss42.com/case/lower', name: 'foss42 api', requestHeaders: const [ - NameValueModel('content-length', '18'), - NameValueModel('content-type', 'application/json; charset=utf-8') + NameValueModel(name: 'content-length', value: '18'), + NameValueModel( + name: 'content-type', value: 'application/json; charset=utf-8') ], requestBodyContentType: ContentType.json, requestBody: '''{ @@ -71,8 +72,9 @@ void main() { url: 'api.foss42.com/case/lower', name: 'foss42 api', requestHeaders: [ - NameValueModel('content-length', '18'), - NameValueModel('content-type', 'application/json; charset=utf-8') + NameValueModel(name: 'content-length', value: '18'), + NameValueModel( + name: 'content-type', value: 'application/json; charset=utf-8') ], requestBodyContentType: ContentType.json, requestBody: '''{ diff --git a/test/request_models.dart b/test/request_models.dart index 6d8fa605..5946321b 100644 --- a/test/request_models.dart +++ b/test/request_models.dart @@ -14,7 +14,7 @@ const requestModelGet2 = RequestModel( url: 'https://api.foss42.com/country/data', method: HTTPVerb.get, 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', method: HTTPVerb.get, requestParams: [ - NameValueModel('code', 'IND'), + NameValueModel(name: 'code', value: 'IND'), ], ); @@ -34,11 +34,11 @@ const requestModelGet4 = RequestModel( url: 'https://api.foss42.com/humanize/social', method: HTTPVerb.get, requestParams: [ - NameValueModel('num', '8700000'), - NameValueModel('digits', '3'), - NameValueModel('system', 'SS'), - NameValueModel('add_space', 'true'), - NameValueModel('trailing_zeros', 'true'), + NameValueModel(name: 'num', value: '8700000'), + NameValueModel(name: 'digits', value: '3'), + NameValueModel(name: 'system', value: 'SS'), + NameValueModel(name: 'add_space', value: 'true'), + NameValueModel(name: 'trailing_zeros', value: 'true'), ], ); @@ -48,7 +48,7 @@ const requestModelGet5 = RequestModel( url: 'https://api.github.com/repos/foss42/apidash', method: HTTPVerb.get, 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', method: HTTPVerb.get, requestHeaders: [ - NameValueModel('Authorization', 'Bearer XYZ'), + NameValueModel(name: 'Authorization', value: 'Bearer XYZ'), ], requestParams: [ - NameValueModel('raw', 'true'), + NameValueModel(name: 'raw', value: 'true'), ], ); diff --git a/test/utils/convert_utils_test.dart b/test/utils/convert_utils_test.dart index 61a32683..26be2c10 100644 --- a/test/utils/convert_utils_test.dart +++ b/test/utils/convert_utils_test.dart @@ -73,18 +73,18 @@ void main() { expect(rowsToMap(null), null); }); test('Testing for string KVRow values', () { - const kvRow1 = NameValueModel("code", "IN"); + const kvRow1 = NameValueModel(name: "code", value: "IN"); expect(rowsToMap([kvRow1]), {"code": "IN"}); }); 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"}); }); test('Testing when header is false and key is in upper case', () { const kvRow3 = [ - NameValueModel("TEXT", "ABC"), - NameValueModel("version", 0.1), - NameValueModel("month", 4), + NameValueModel(name: "TEXT", value: "ABC"), + NameValueModel(name: "version", value: 0.1), + NameValueModel(name: "month", value: 4), ]; expect( rowsToMap(kvRow3), {"TEXT": "ABC", "version": "0.1", "month": "4"}); @@ -98,9 +98,9 @@ void main() { test('Testing with a map value', () { Map value1 = {"text": "abc", "lang": "eng", "code": "1"}; const result1Expected = [ - NameValueModel("text", "abc"), - NameValueModel("lang", "eng"), - NameValueModel("code", "1") + NameValueModel(name: "text", value: "abc"), + NameValueModel(name: "lang", value: "eng"), + NameValueModel(name: "code", value: "1") ]; expect(mapToRows(value1), result1Expected); }); diff --git a/test/utils/http_utils_test.dart b/test/utils/http_utils_test.dart index 6d98c28b..4fe46f15 100644 --- a/test/utils/http_utils_test.dart +++ b/test/utils/http_utils_test.dart @@ -176,7 +176,7 @@ void main() { group("Testing getValidRequestUri", () { test('Testing getValidRequestUri for normal values', () { String url1 = "https://api.foss42.com/country/data"; - const kvRow1 = NameValueModel("code", "US"); + const kvRow1 = NameValueModel(name: "code", value: "US"); Uri uri1Expected = Uri( scheme: 'https', host: 'api.foss42.com', @@ -185,16 +185,16 @@ void main() { expect(getValidRequestUri(url1, [kvRow1]), (uri1Expected, null)); }); 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!")); }); test('Testing getValidRequestUri for empty url value', () { - const kvRow3 = NameValueModel("", ""); + const kvRow3 = NameValueModel(name: "", value: ""); expect(getValidRequestUri("", [kvRow3]), (null, "URL is missing!")); }); test('Testing getValidRequestUri when https is not provided in url', () { String url4 = "api.foss42.com/country/data"; - const kvRow4 = NameValueModel("code", "US"); + const kvRow4 = NameValueModel(name: "code", value: "US"); Uri uri4Expected = Uri( scheme: 'https', host: 'api.foss42.com', @@ -218,7 +218,7 @@ void main() { test('Testing getValidRequestUri when query params in both url and kvrow', () { String url6 = "api.foss42.com/country/data?code=IND"; - const kvRow6 = NameValueModel("code", "US"); + const kvRow6 = NameValueModel(name: "code", value: "US"); Uri uri6Expected = Uri( scheme: 'https', host: 'api.foss42.com', diff --git a/test/widgets/response_widgets_test.dart b/test/widgets/response_widgets_test.dart index 1c48d8e1..632d29bd 100644 --- a/test/widgets/response_widgets_test.dart +++ b/test/widgets/response_widgets_test.dart @@ -204,8 +204,9 @@ void main() { url: 'api.foss42.com/case/lower', name: 'foss42 api', requestHeaders: [ - NameValueModel('content-length', '18'), - NameValueModel('content-type', 'application/json; charset=utf-8') + NameValueModel(name: 'content-length', value: '18'), + NameValueModel( + name: 'content-type', value: 'application/json; charset=utf-8') ], requestBodyContentType: ContentType.json, requestBody: '''{