[英]The constructor being called isn't a const constructor?
I am brand new to flutter and programming in general -so please bear with me-, so I am taking a course on udemy and I stumbled with this error (The constructor being called isn't a const constructor) This is the code:我是 flutter 和一般编程的新手 - 所以请耐心等待 - 所以我正在上 udemy 的课程,我偶然发现了这个错误(被调用的构造函数不是 const 构造函数)这是代码:
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar:AppBar(
title: Text('My First App'),
),
body: Text('This is my default text'),
),
);
}
}
Try below code hope its help to you.试试下面的代码希望它对你有帮助。 remove
const
keyword删除
const
关键字
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('My First App'),
),
body: Text('This is my default text'),
),
);
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.