Posts

Showing posts from June, 2024

Widget Life Cycle In Flutter

Image
  Widget Life Cycle In Flutter Flutter has two types of widgets Stateless Widget, and Stateful Widget. Stateless Widget Stateless Widgets are rendered only once when the widget is loaded. We can't rebuild a Stateless widget based on any user events or changes. Stateful Widgets Stateful Widgets can be rebuilt and have their own Widget Lifecycle to create, update and destroy the widgets. In Flutter, widgets have several lifecycle methods that the framework calls during different stages of their lifecycle. Here are the most important ones: createState(): This method is called during the construction stage of a Stateful widget and creates a corresponding state object. initState(): This method is called during the initialization stage of stateful widget and is used to initialize any resources the widget needs. didChangeDependencies(): This method is called during the dependecies resolution stage of a widget, and is used to handle any changes to the widget's dependencies. build():

Sync&Async with flutter

Image
 Sync & Async Flutter Asynchronous (async) and synchronous (sync) programming are fundamental concepts in modern   software development, especially in mobile application development using Flutter.   Synchronous Programming Synchronous programming, often referred to as "sync," is a straightforward approach where tasks are executed sequentially. In this model, each task waits for the previous one to complete before it starts. This can lead to a blocking operation where the application becomes unresponsive if a task takes a long time to complete.   Example:    void main() {   print('Task 1');   print('Task 2');   print('Task 3'); } Output Task 1 Task 2 Task 3 Each task waits for the previous one to complete, ensuring a predictable and ordered execution.   Asynchronous Programming   Asynchronous programming, or "async," allows multiple tasks to run concurrently without waiting for each other to complete. This is partic