Flutter 新项目显示密钥错误,当我单击运行按钮时,它显示这些错误,
注意:我正在使用所有更新的最新版本工具。
我的代码如下:
import 'package:flutter/material.dart';
void main(){
runApp(MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key key}) : super(key: key);
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Container(
child: Text("Hello World"),
),
);
}
}
Run Code Online (Sandbox Code Playgroud)
小智 7
这是关于 dart 的空安全特性。当您使用命名参数时,您需要提供默认的非空值或使用可为空的值。例如
const MyApp({Key? key}) : super(key: key);
或者
const MyApp({Key key = const GlobalKey()}) : super(key: key);
| 归档时间: |
|
| 查看次数: |
7086 次 |
| 最近记录: |