I wanted to display my Tabs using a sectors' list (Sector model) which I'm getting from Api like shown bellow:
SizedBox(
child: DefaultTabController(
initialIndex: 1,
length: sectorsProvider.sectorList.length,
child: DecoratedBox(
decoration: BoxDecoration(
//This is for background color
color: Colors.white.withOpacity(0.0),
//This is for bottom border that is needed
border: Border(
bottom: BorderSide(color: Colors.white, width: 0.4),
),
),
child: ListView(
shrinkWrap: true,
children: [
TabBar(
isScrollable: true,
indicatorColor: Colors.black,
controller: _tabController,
indicatorSize: TabBarIndicatorSize.label,
indicatorWeight: 3.0,
labelStyle: TextStyle(
fontSize: 22.0,
),
// unselectedLabelStyle: TextStyle(fontSize: 10.0, color: Colors.black26,),
tabs: (sectorsProvider.sectorList as List<Sector>).map((index) => Tab(text: sectorsProvider.sectorList[index as int].name)).toList(),
),
],
),
),
),
),
I had the following error : type 'Sector' is not a subtype of type 'int' in type cast..
thanks for help!