【发布时间】:2021-10-17 18:46:57
【问题描述】:
我刚刚创建了一个新的颤振项目,当我尝试在 Material 应用程序中定义“home”属性时,我收到以下错误:“未定义参数“home”。”
可能与它有关的是我刚刚将我的 sdk 更新为:
environment:
sdk: ">=2.12.0 <3.0.0"
之后我把它改回:
environment:
sdk: ">=2.7.0 <3.0.0"
当我打开 Material 类时,我看到类中没有与路由相关的属性。
这是我的 main.dart 代码:
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Material(home: );
}
}
and this is the code
Material 类(我没有更改,但创建时是这样的):
const Material({
Key? key,
this.type = MaterialType.canvas,
this.elevation = 0.0,
this.color,
this.shadowColor,
this.textStyle,
this.borderRadius,
this.shape,
this.borderOnForeground = true,
this.clipBehavior = Clip.none,
this.animationDuration = kThemeChangeDuration,
this.child,
}) : assert(type != null),
assert(elevation != null && elevation >= 0.0),
assert(!(shape != null && borderRadius != null)),
assert(animationDuration != null),
assert(!(identical(type, MaterialType.circle) && (borderRadius != null || shape != null))),
assert(borderOnForeground != null),
assert(clipBehavior != null),
super(key: key);
如您所见,不再有 home 或 routes 属性。当我打开一个旧项目时,它确实具有这些属性。
有人知道发生了什么吗?
【问题讨论】:
-
将您的
MaterialApp代码添加到问题中
标签: flutter android-studio material-components-android