// I cant find a way to pass a string from a class to another. They are both in the same screen and i want to pass the index from a pageview on class to another. Any help would be grateful!
//on the first class//
onPageChanged: (int index) {
_sendDataToAnotherClass(context, index);
_currentPageNotifier.value = index;
}),
),
);
}
void _sendDataToAnotherClass(BuildContext context, int index) {
final String texttosend = index.toString();
Navigator.of(context).push(
MaterialPageRoute(
builder: (context) {
return new personaname(text: texttosend);
}
));
}
//on the second class//
final String text ;
personaname({Key key, @required this.text}) : super(key: key);