3

when I am signing up using this time user has to fill 4 forms and at the end of the gets all the details displayed in last display form when I click on particular form edit button it will redirect back to the form field and then I can edit it. I hope you understand the question. can anyone help me? thank you in advance.

I'll explain to you using this image. in this image, there is on business details container when I click on the edit of this container. it will get back to the business details page and i can able to edit these fields.

Here is the image

enter image description here

Rutvik Gumasana
  • 1,458
  • 11
  • 42
  • 66

2 Answers2

0

If I understand want you want to accomplish, that when a user tap the edit(pencil) icon the app navigates to another page where the user could change the data fields, is it?

To send data to a router destiny constructor you can use:

Navigator.push(
  context,
  MaterialPageRoute(builder: (context) {
    return ResultPage(
      bmiResult: calc.calculateBMI(),
      resultText: calc.getResult()
    );
  }),
);

//In the destiny you can recover the information:
class ResultPage extends StatelessWidget {
  ResultPage( {@required this.bmiResult,@required this.resultText});
  final String bmiResult;
  final String resultText;
  @override
  Widget build(BuildContext context) {
   ...
Daniel
  • 1,007
  • 1
  • 11
  • 23
0

For a simpler solution, you can store the data a Map<String, dynamic> (can also be `Map>.

On every TextFormField's onSave or onChange, you can set the value of the Map. Example:

TextFormField(
  // We set the initial value of the text field here
  initialValue: _map['firstName'] ?? '',
  onSave: (String value) {
    _map['firstName'] = value;
  }
)

Then you will pass the Map to the next page/screen.

Navigator.of(context).push(
  MaterialPageRoute(
   // We pass the Map to the next screen
   builder: (_) => MyNextScreen(data: _map),
  ),
);

If you use the pushReplacement and want to go to the business details route/screen, then just past the Map again.

Navigator.of(context).push(
  MaterialPageRoute(
   // We pass the Map to the next screen
   builder: (_) => BusinessDetailScreen(data: _map),
  ),
);

UPDATE

TextField doesn't have the initialValue property, can you try using TextFormField?

Here is the example how to have a filled (initial value) TextFormField

TextFormField(
          // We set the value of the TextFormField
          initialValue: _map['business_name'],
          onSaved: (value) {
            _map['business_name'] = value;
          },
        )
Kokuou
  • 129
  • 2
  • 9
  • in the first phase, I am already filling this form and then click on the next button then it will show me the data as in the above image when i click on that edit icon it will get back to redirect me the appropriate page. – Rutvik Gumasana Oct 14 '19 at 06:17
  • thanks but what if there is Dropdown, imagepicker,?? – Rutvik Gumasana Oct 14 '19 at 06:31
  • for dropdown, you just need to pass the `value`. DropdownButton have a parameter `value` which you can pass something like `_map['business_type']` – Kokuou Oct 15 '19 at 02:52