【发布时间】:2023-02-05 21:49:50
【问题描述】:
void main() {
runApp(
const MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('I am Rich'),
),
),
),
);
}
这是我的代码,显示“调用的构造函数不是构造函数”
错误信息-
lib/main.dart:8:17: Error: Cannot invoke a non-'const' constructor where a const expression is expected.
Try using a constructor or factory that is 'const'.
appBar: AppBar(
^^^^^^
tried adding 'const' before scaffold
我很抱歉这个愚蠢的问题。我只是一个初学者。在其他任何地方都找不到解决方案。
【问题讨论】:
标签: flutter dart appbar scaffold