【问题标题】:custom AppBar The element type 'List<dynamic>' can't be assigned to the list type自定义 AppBar 元素类型 'List<dynamic>' 不能分配给列表类型
【发布时间】:2021-12-14 14:39:04
【问题描述】:
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 类中使用选项卡变量,但出现此错误。 tabs: tabs 行给出这个错误。

任何帮助

【问题讨论】:

  • 如何将List tabs; 转为List&lt;Widget&gt; tabs;
  • 运算符 '

标签: flutter dart flutter-getx


【解决方案1】:

List tabs; 替换为List&lt;Widget&gt; tabs; 并提供如下标签 tabs: tabs,

 TabBar(
      labelColor: Colors.purple[100],
      indicatorColor: Colors.purple,
      isScrollable: true,
      labelPadding: const EdgeInsets.symmetric(horizontal: 8.0),
      tabs: tabs,
    );

它能解决你的问题吗?

【讨论】:

    猜你喜欢
    • 2019-11-29
    • 2018-10-27
    • 2021-09-15
    • 2021-10-18
    • 2021-09-10
    • 2021-10-24
    • 1970-01-01
    • 1970-01-01
    • 2020-10-11
    相关资源
    最近更新 更多