最近开始关注Flitter udacity course,在try 创建基本应用程序时,我遇到了一些我不清楚的事情.在添加小部件时,我注意到new Widget()
和Widget()
[where Widget is any widget being added to the tree]都会得到相同的结果.是否有一个特定的时间,你应该使用new Widget()
和一个时间,你应该省略new
关键字?
例如:
return MaterialApp(
debugShowCheckedModeBanner: false,
home: new Scaffold(
appBar: new AppBar(
title: Text('My app name')
),
)
Text('My app name')
个有效,但new Text('My app name')
个也有效.有没有可能给我一些关于最佳实践的建议和指导?