Tuesday, March 13, 2018

How to change text status as soon as a button is pressed in Flutter SDK and Dart.

To explain this I am going to use a simple code that update a text widget when ever a button is pressed.

You may know there are two classes, actually three, those are


  1. Stateless Widget
  2. Stateful Widget
  3. Inherited Widget
Stateless Widget is immutable and when we want to change something that displaying we need to create new one.

Stateful Widget is mutable and can interact with users. When we want to redraw/ change something that displaying we need to use this widget. To use this widget we need two classes. And to redraw the display we have a method call setState().

Inherited Widget is mix of both of above.

I think now you understand what is the widget that we need to use for this situation. It is stateful widget. You guess it right?

So here is the complete code, and I'll explain it one by one.


No comments:

Post a Comment