Home > OS >  custom AppBar The element type 'List<dynamic>' can't be assigned to the list ty
custom AppBar The element type 'List<dynamic>' can't be assigned to the list ty

Time:10-30

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);
}

Hello,

I am trying to use tab variables in customAppBar class but I am getting this error. tabs: tabs line gives this error.

any help

CodePudding user response:

Replace List tabs; with List<Widget> tabs; and provide tabs like tabs: tabs,

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

does it solve your issue?

  • Related