Flutter stateless and stateful widget question

46 views Asked by At

I just wanna ask few questions

  1. Should i wrap my normal widget with stateless or stateful when using?
  2. What is the different of using it as is?

I just wanna build re usable widget and wondering if i should wrap it before re using! Thanks for answering

1

There are 1 answers

0
Ivone Djaja On BEST ANSWER

Use StatelessWidget if your widget will not change value. For example: If you want to display a Container with color red and it is not going to change colour.

Use StatefulWidget if your widget will change value. For example: If you want to display a number 10, and this number will be increased to 11 or decreased to 9 by pressing a button.