mirror of
https://github.com/foss42/apidash.git
synced 2025-08-06 13:51:20 +08:00
Update request_params.dart
This commit is contained in:
@ -7,6 +7,8 @@ import 'package:apidash/widgets/widgets.dart';
|
|||||||
import 'package:apidash/models/models.dart';
|
import 'package:apidash/models/models.dart';
|
||||||
import 'package:apidash/consts.dart';
|
import 'package:apidash/consts.dart';
|
||||||
|
|
||||||
|
const kNameValueEmptyModel = NameValueModel(name: "", value: "");
|
||||||
|
|
||||||
class EditRequestURLParams extends ConsumerStatefulWidget {
|
class EditRequestURLParams extends ConsumerStatefulWidget {
|
||||||
const EditRequestURLParams({Key? key}) : super(key: key);
|
const EditRequestURLParams({Key? key}) : super(key: key);
|
||||||
|
|
||||||
@ -39,7 +41,9 @@ class EditRequestURLParamsState extends ConsumerState<EditRequestURLParams> {
|
|||||||
.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)
|
rows = (rP == null || rP.isEmpty)
|
||||||
? [const NameValueModel(name: "", value: "")]
|
? [
|
||||||
|
kNameValueEmptyModel,
|
||||||
|
]
|
||||||
: rP;
|
: rP;
|
||||||
|
|
||||||
DaviModel<NameValueModel> model = DaviModel<NameValueModel>(
|
DaviModel<NameValueModel> model = DaviModel<NameValueModel>(
|
||||||
@ -99,9 +103,6 @@ class EditRequestURLParamsState extends ConsumerState<EditRequestURLParams> {
|
|||||||
? kIconRemoveDark
|
? kIconRemoveDark
|
||||||
: kIconRemoveLight,
|
: kIconRemoveLight,
|
||||||
onTap: () {
|
onTap: () {
|
||||||
if (rows.length == 1) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
rows.removeAt(row.index);
|
rows.removeAt(row.index);
|
||||||
seed = random.nextInt(kRandMax);
|
seed = random.nextInt(kRandMax);
|
||||||
_onFieldChange(activeId!);
|
_onFieldChange(activeId!);
|
||||||
@ -136,7 +137,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(name: "", value: ""));
|
rows.add(kNameValueEmptyModel);
|
||||||
_onFieldChange(activeId!);
|
_onFieldChange(activeId!);
|
||||||
},
|
},
|
||||||
icon: const Icon(Icons.add),
|
icon: const Icon(Icons.add),
|
||||||
|
Reference in New Issue
Block a user