Skip to content

Commit

Permalink
After create fail, Create again with the draft
Browse files Browse the repository at this point in the history
  • Loading branch information
HaitaoDeng committed Mar 17, 2022
1 parent d462e4f commit 1b866a1
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion lib/ui/util/form_util.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand All @@ -32,6 +33,8 @@ class FormUtil {
static const String CANCEL = 'cancel';
static const String CREATE = 'create';

static Map<String, Map<String, String>> lastMap = new HashMap();

static ButtonStyleButton createButton5(String resourceName, List<FormFieldDef> formFieldDefList, BuildContext context,
Function(String, String, String, String, String) callback) {
if (formFieldDefList.length != 5) {
Expand Down Expand Up @@ -76,9 +79,14 @@ class FormUtil {

static ButtonStyleButton createButton(
String resourceName, List<FormFieldDef> formFieldDefList, BuildContext context, Function(List<String>) 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<TextFormField> formFieldsList = List.generate(
formFieldDefList.length,
(index) => TextFormField(
Expand All @@ -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();
},
),
Expand Down

0 comments on commit 1b866a1

Please sign in to comment.