Search code examples
flutterflutter-getx

How to change text value of several pages at the same time


I am using GetX to develop an App. I have several pages that should show the same text value(Every page has its own text widget, and these text widgets should show the same value). When I click a button in Setting Page. These pages should change the text value at the same time? How to accomplish global notification in GetX.


Solution

  • You should declare the value you want to show across your app to be observable so the controller can keep track of it

    String sameValue = "same value".obs;

    and the way you want show it on the UI is like

    Obx(() => Text("${your_controller.sameValue}"))