小部件不是一种类型
Widget isn't a type
当我创建一个新的 Widget 时,uper widget 显示错误。
Widget isn't a type.
问题出在您命名为 Widget 的函数上...更改其名称
flutter 中的一切都是一个 widget,如果你想创建自己的 widget 来重用它,你可以这样做:
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Column(
children: [
Container(
height: 56.0,
padding: const EdgeInsets.symmetric(horizontal: 8.0),
decoration: BoxDecoration(color: Colors.blue[500]),
child: Card(),
),
],
);
}
}
创建可重复使用的小部件后,您可以将其导入到您想要使用的地方。
当我创建一个新的 Widget 时,uper widget 显示错误。
Widget isn't a type.
问题出在您命名为 Widget 的函数上...更改其名称
flutter 中的一切都是一个 widget,如果你想创建自己的 widget 来重用它,你可以这样做:
class MyWidget extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Column(
children: [
Container(
height: 56.0,
padding: const EdgeInsets.symmetric(horizontal: 8.0),
decoration: BoxDecoration(color: Colors.blue[500]),
child: Card(),
),
],
);
}
}
创建可重复使用的小部件后,您可以将其导入到您想要使用的地方。