How to pass a function return value to another class

Hi ! I have a map of different places in my application and a carousel widget (detail of the places). All places have a small icon but i want that the one that is display in the carousel have another.

I’ve created a function wich is called in carousel.slider and store the id of the places in variable called idcarousel. i’d trie to pass this variable to my class “map” but when i call my variable in my class map like print(‘carouselval :$idcarousel’) the anwser i got is : carouselval :null.

My question is how do you do to get access to a function store in another page of your project and in another class ?

FirstPage.dart

 Navigator.push(
          context,
          MaterialPageRoute(
              builder: (context) => PasswordRoute(usernameController)));

//usernameController is String value,If you want to pass multiple values add all

SecondPage.dart

class PasswordRoute extends StatefulWidget {
  final String usernameController;//if you have multiple values add here
PasswordRoute(this.usernameController, {Key key}): super(key: key);//add also..example this.abc,this...

  @override
  State<StatefulWidget> createState() => _PasswordPageState();
}

class _PasswordPageState extends State<PasswordRoute> {
 @override
  Widget build(BuildContext context) {
...child: Text(widget.usernameController);
}
}