The constructor being called isn‘t a const constructor.

初学Flutter在初始化Appbar的时候编译报了这个错误

void main(){
  runApp(const MaterialApp(
    title: 'Shopping App',
    home: Scaffold(
      appBar: AppBar(title: Text("HMOE")),
      body: NavigatorWidget(),
    ),
  ));
}

去掉修饰MaterialApp的const解决了这个问题。

猜你喜欢

转载自blog.csdn.net/mldxs/article/details/129967307