As you can see, these two code snippets are customTextWidget which returns Text(). But snippet1 uses a Stless(class), snippet2 uses a Function. When I run both of these codes, they return the same result on the screen.
snippet1
class TextWidget extends StatelessWidget{
@override
Widget build(BuildContext context) {
return Text("Hello World");
}
}
snippet2
Widget TextWidget() {
return Text("Hello World");
}
I want to know the difference between these two snippets for creating custom widgets.