What is StatefulWidget in Flutter?
This answer contains multi-languages such like English, Hindi and Gujarati.
2 min readApr 5, 2023
In English:
- This is a kind of widget which is dynamic and placed inside a memory (RAM).
- Using this widget we can update an UI using its lifecycle method setState().
- Since this widget did created in memory frequently, this supplies slow performance as compared to StatelesWidget.
- This widget contains many lifecycle methods, such as
- createState()
- initState()
- build()
- setState()
- dispose() and many more…
How to create StateefulWidget?
class HomePage extends StatefulWidget {
@override
State<HomePage> createState() => _HomePageState();
}
class _HomePageState extends State<HomePage> {
@override
Widget build(BuildContext context) {
return Container();
}
}
In Hindi:
- यह एक ऐसा widget है जो की dynamic है और memory (RAM) के अंदर बनता है |
- इस widget की lifecycle method setState() की मदद से हम UI को update कर सक्ते है |
- क्यूँकि यह widget memory में बारबार बनता है, इसलिए यह widget StatelessWidget के मुकाबले slow performance देता है |
- यह widget कई सारी lifecycle methods प्रदान करता है, जैसे की
- createState()
- initState()
- build()
- setState()
- dispose() और कई सारी …
In Gujarati:
- આ widget dynamic હોય છે અને memory (RAM) માં બનતો હોય છે.
- આ widget ની lifecycle method setState() ની મદદ થી UI ને update કરી શકાય છે.
- આ widget memory (RAM) માં વારંવાર બનતો હોવાથી StatelesWidget ની સરખામણી માં ધીમું performance આપે છે.
- આ widget ઘણી lifecycle methods ધરાવે છે, જેવી કે
- createState()
- initState()
- build()
- setState()
- dispose() અને ઘણી બધી …