自定义AppBar 元素类型'List<dynamic>'无法赋值给列表类型
custom AppBar The element type 'List<dynamic>' can't be assigned to the list type
class BottomOfAppBar extends StatelessWidget implements PreferredSizeWidget {
BottomOfAppBar({Key? key, required this.tabs}) : super(key: key);
List tabs;
@override
Widget build(BuildContext context) {
return Obx(() => Container(
child: ColoredBox(
color: Colors.white,
child: Column(
children: [
widget.tabbarenable
? TabBar(
labelColor: Colors.purple[100],
indicatorColor: Colors.purple,
isScrollable: true,
labelPadding:
const EdgeInsets.symmetric(horizontal: 8.0),
tabs: <Widget>[tabs])
: Container()
],
),
),
));
}
@override
Size get preferredSize => const Size.fromHeight(55.0);
}
您好,
我正在尝试在 customAppBar class 中使用选项卡变量,但出现此错误。制表符:制表符行给出此错误。
任何帮助
将 List tabs;
替换为 List<Widget> tabs;
并提供选项卡,例如
tabs: tabs,
TabBar(
labelColor: Colors.purple[100],
indicatorColor: Colors.purple,
isScrollable: true,
labelPadding: const EdgeInsets.symmetric(horizontal: 8.0),
tabs: tabs,
);
它能解决您的问题吗?
class BottomOfAppBar extends StatelessWidget implements PreferredSizeWidget {
BottomOfAppBar({Key? key, required this.tabs}) : super(key: key);
List tabs;
@override
Widget build(BuildContext context) {
return Obx(() => Container(
child: ColoredBox(
color: Colors.white,
child: Column(
children: [
widget.tabbarenable
? TabBar(
labelColor: Colors.purple[100],
indicatorColor: Colors.purple,
isScrollable: true,
labelPadding:
const EdgeInsets.symmetric(horizontal: 8.0),
tabs: <Widget>[tabs])
: Container()
],
),
),
));
}
@override
Size get preferredSize => const Size.fromHeight(55.0);
}
您好,
我正在尝试在 customAppBar class 中使用选项卡变量,但出现此错误。制表符:制表符行给出此错误。
任何帮助
将 List tabs;
替换为 List<Widget> tabs;
并提供选项卡,例如
tabs: tabs,
TabBar(
labelColor: Colors.purple[100],
indicatorColor: Colors.purple,
isScrollable: true,
labelPadding: const EdgeInsets.symmetric(horizontal: 8.0),
tabs: tabs,
);
它能解决您的问题吗?