What is the difference between functions and classes to create reusable widgets?

后端 未结 5 2100
野的像风
野的像风 2020-11-22 10:20

I have realized that it is possible to create widgets using plain functions instead of subclassing StatelessWidget. An example would be this:

Widget functio         


        
5条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-22 11:07

    When you are calling the Flutter widget make sure you use the const keyword. For example const MyListWidget();

提交回复
热议问题