Stlesswidget lifecycle.

Stlesswidget lifecycle.

In Flutter, StatelessWidget is a basic building block for creating user interfaces. Unlike StatefulWidget, StatelessWidget does not have a mutable state. It means that once a Stateless widget is created, its properties cannot change. Here is an overview of the lifecycle of a StatelessWidget:

  1. Initialization:

  • When a StatelessWidget is created, its constructor is called.?

class MyStatelessWidget extends StatelessWidget {
  final String title;

  MyStatelessWidget({required this.title});

  // Other widget code...
}        

2. Build Method:

  • The build method is called when the widget is first created and whenever it needs to rebuild

@override
Widget build(BuildContext context) {
  return Scaffold(
    appBar: AppBar(
      title: Text(title),
    ),
    body: // Widget body...
  );
}        


要查看或添加评论,请登录

Eslam Elezaby的更多文章

  • Color conversion in Flutter

    Color conversion in Flutter

    ?? Excited to share a handy code snippet for color conversion in Flutter! ?? Have you ever needed to convert color…

  • StatefulWidget lifecycle:

    StatefulWidget lifecycle:

    1- This method is called only once during the widget's lifetime. the framework calls the method of the associated to…

  • OOP in Brief

    OOP in Brief

    Class: A blueprint or template for creating objects defines the properties and behaviors common to all objects. Object:…

  • What is SOLID ?

    What is SOLID ?

    Single Responsibility: a class should have only one responsibility or job. Open/Closed: Software entities ( classes…

  • Array and Linked?List.

    Array and Linked?List.

    Array Arrays have a fixed size meaning that you need to specify the array size when you declare it. All elements in an…

社区洞察

其他会员也浏览了