What is Stateless Widget ?
Flutter Stateless widgets are those components that describe a part of the user interface which can be determined only by configurations in the constructor. They don't store mutable states. Examples of Stateless widgets are Icon, IconButton, and Text.
Lifecycle of a Stateless Widget in Flutter :
Creation of a Stateless Widget :
As we've seen, a stateless widget is easy to instantiate. You create an instance of it and Flutter takes care of the rest. It will render the widget and then destroy it.
Example :
import 'package:flutter/material.dart';
class TextWidget extends StatelessWidget {
const TextWidget({super.key});
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(),
body: const Text(
'# hiii how are you!. ',
),
);
}
}