passing data or parameters from embedded file to main page in flutter

34 views Asked by At

To be able to easily explain what I need, I prepared the following image.

enter image description here

Shortly, I have a homepage.dart page and I embedded a map1.dart page into it. when user taps on the map, it creates a small node and adds the point into "createdMarkerPoints[]" array. I want to pass any data (List createdMarkerPoints[]) from map1.dart to a component on homepage.dart file, when:

  1. user clicks a button at homepage.dart (triggered at homepage.dart)
  2. user taps on the map at map1.dart (triggered at map1.dart)

Thank you for helps.

1

There are 1 answers

0
SilkeNL On

You could move List createdMarkerPoints to homepage.dart and then give a function that adds to createdMarkerPoints to map1.dart. This is a callback function.

This article gives some examples: https://medium.com/@dnkibere/passing-a-function-as-an-argument-flutter-e011ad2afd86