Home > Mobile >  How to use string data from another class in flutter
How to use string data from another class in flutter

Time:09-30

I have a string named label that contains the value 'Next'. I have passed the value to another class but am not able to use it in the Text widget. I have send the value is this manner. MainButton(label: 'GetStarted',tapEvent: () { }, ) but not able to use in another class class MainButton extends StatefulWidget { const MainButton({Key? key, required String label, required this.tapEvent}) : super(key: key); how to use the String label in text

CodePudding user response:

Depending on when in the life-cycle you are populating the Text(...) Widget. You might need to use SetState( () {} ) to trigger a re-build of the Widget to show the label.

That could be the problem.

  • Related