How to use string data from another class in flutter

Issue

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

Solution

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.

Answered By – Hesam Chobanlou

Answer Checked By – Terry (FlutterFixes Volunteer)

Leave a Reply

Your email address will not be published.