From cf13b6b2f0c8a982f6148b5248d30bbb4c529f41 Mon Sep 17 00:00:00 2001 From: jaime <819519812@qq.com> Date: Thu, 17 Mar 2022 12:40:38 +0800 Subject: [PATCH] After create fail, Create again with the draft --- lib/ui/util/form_util.dart | 30 +++++++++++++++++++++++++++--- pubspec.yaml | 2 +- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/lib/ui/util/form_util.dart b/lib/ui/util/form_util.dart index fc6d7ba..9347d60 100644 --- a/lib/ui/util/form_util.dart +++ b/lib/ui/util/form_util.dart @@ -18,6 +18,7 @@ // import 'dart:collection'; + import 'package:flutter/material.dart'; import 'package:paas_dashboard_flutter/generated/l10n.dart'; import 'package:paas_dashboard_flutter/module/util/csv_utils.dart'; @@ -32,6 +33,8 @@ class FormUtil { static const String CANCEL = 'cancel'; static const String CREATE = 'create'; + static Map> lastMap = new HashMap(); + static ButtonStyleButton createButton5(String resourceName, List formFieldDefList, BuildContext context, Function(String, String, String, String, String) callback) { if (formFieldDefList.length != 5) { @@ -76,9 +79,14 @@ class FormUtil { static ButtonStyleButton createButton( String resourceName, List formFieldDefList, BuildContext context, Function(List) callback) { + lastMap.putIfAbsent( + resourceName, + () => HashMap.fromIterables( + formFieldDefList.map((e) => e.fieldName).toList(), Iterable.generate(formFieldDefList.length, (i) => ""))); return TextButton( onPressed: () { - var editControllerList = formFieldDefList.map((e) => TextEditingController()).toList(); + var editControllerList = + formFieldDefList.map((e) => TextEditingController(text: lastMap[resourceName]![e.fieldName])).toList(); List formFieldsList = List.generate( formFieldDefList.length, (index) => TextFormField( @@ -101,6 +109,8 @@ class FormUtil { onPressed: () { var list = editControllerList.map((e) => e.value.text).toList(); callback(list); + lastMap[resourceName] = HashMap.fromIterables(formFieldDefList.map((e) => e.fieldName).toList(), + editControllerList.map((e) => e.value.text)); Navigator.of(context).pop(); }, ), @@ -127,9 +137,14 @@ class FormUtil { static ButtonStyleButton createButtonNoText( String resourceName, List formFieldDefList, BuildContext context, Function(List) callback) { + lastMap.putIfAbsent( + resourceName, + () => HashMap.fromIterables( + formFieldDefList.map((e) => e.fieldName).toList(), Iterable.generate(formFieldDefList.length, (i) => ""))); return TextButton( onPressed: () { - var editControllerList = formFieldDefList.map((e) => TextEditingController()).toList(); + var editControllerList = + formFieldDefList.map((e) => TextEditingController(text: lastMap[resourceName]![e.fieldName])).toList(); List formFieldsList = List.generate( formFieldDefList.length, (index) => TextFormField( @@ -152,6 +167,8 @@ class FormUtil { onPressed: () { var list = editControllerList.map((e) => e.value.text).toList(); callback(list); + lastMap[resourceName] = HashMap.fromIterables(formFieldDefList.map((e) => e.fieldName).toList(), + editControllerList.map((e) => e.value.text)); Navigator.of(context).pop(); }, ), @@ -194,9 +211,14 @@ class FormUtil { static ButtonStyleButton updateButton( String resourceName, List formFieldDefList, BuildContext context, Function(List) callback) { + lastMap.putIfAbsent( + resourceName, + () => HashMap.fromIterables( + formFieldDefList.map((e) => e.fieldName).toList(), Iterable.generate(formFieldDefList.length, (i) => ""))); return TextButton( onPressed: () { - var editControllerList = formFieldDefList.map((e) => TextEditingController()).toList(); + var editControllerList = + formFieldDefList.map((e) => TextEditingController(text: lastMap[resourceName]![e.fieldName])).toList(); List formFieldsList = List.generate( formFieldDefList.length, (index) => TextFormField( @@ -219,6 +241,8 @@ class FormUtil { onPressed: () { var list = editControllerList.map((e) => e.value.text).toList(); callback(list); + lastMap[resourceName] = HashMap.fromIterables(formFieldDefList.map((e) => e.fieldName).toList(), + editControllerList.map((e) => e.value.text)); Navigator.of(context).pop(); }, ), diff --git a/pubspec.yaml b/pubspec.yaml index aa67978..2229c0f 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -53,7 +53,7 @@ dependencies: # window window_size: git: - url: git://github.com/google/flutter-desktop-embedding.git + url: https://github.com/google/flutter-desktop-embedding.git path: plugins/window_size # paas http: ^0.13.4