I have two TabBars in one screen and when their TabBarViews are showing in half of the screen (view of first tabbar is showing upper half of the screen and seconf tabbar view is showing bottom half of the screen) but I want to display one TabBarView in full size of the screen. how will I achieve this?
This is the code of the screen where TabBar and TabBarViews are:
import 'package:betting_app/ui/betslip/betslip_active.dart';
import 'package:betting_app/ui/betslip/betslip_settled.dart';
import 'package:betting_app/ui/betslip/parlay_tab_view.dart';
import 'package:flutter/material.dart';
import 'package:flutter_screenutil/flutter_screenutil.dart';
import '../../core/constants/colors.dart';
import 'betslip_bottomsheet.dart';
class BetSlipTabBarView extends StatefulWidget {
const BetSlipTabBarView({Key? key}) : super(key: key);
@override
State<BetSlipTabBarView> createState() => _BetSlipTabBarViewState();
}
class _BetSlipTabBarViewState extends State<BetSlipTabBarView> with TickerProviderStateMixin {
final List<Tab> myTabs = const <Tab>[
Tab(
child: Center(
child: Text(
'Working', style: TextStyle(fontWeight: FontWeight.bold),
),
),
),
Tab(
child: Center(
child: Text(
'Active', style: TextStyle(fontWeight: FontWeight.bold)
),
),
),
Tab(
child: Center(
child: Text(
'Settled',
style: TextStyle(fontSize: 12, fontWeight: FontWeight.bold),
),
),
),
];
final List<Tab> mySecondTabs = <Tab>[
Tab(
child: Center(
child: Text(
'Standard', style: TextStyle(fontWeight: FontWeight.bold),
),
),
),
Tab(
child: Center(
child: Text(
'Parlay', style: TextStyle(fontWeight: FontWeight.bold)
),
),
),
Tab(
child: Center(
child: Text(
'Teaser',
style: TextStyle(fontSize: 12, fontWeight: FontWeight.bold),
),
),
),
];
late TabController _tabController;
late TabController _secondTabbarController;
int _selectedIndex = 0;
int _otherSelectedIndex = 0;
@override
void initState() {
super.initState();
_tabController = TabController(
vsync: this, length: myTabs.length, initialIndex: _selectedIndex);
// Second TabBar Controller
_secondTabbarController = TabController(
vsync: this, length: mySecondTabs.length, initialIndex: _otherSelectedIndex);
}
@override
Widget build(BuildContext context) {
return Scaffold(
body: SafeArea(
child: Column(
children: [
SizedBox(height: 5,),
Row(
children: [
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(7)),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: const Offset(0, 3), // changes position of shadow
),
],
),
height: MediaQuery.of(context).size.height * 0.06,
width: MediaQuery.of(context).size.width,
child: Row(
children: [
const Padding(
padding: EdgeInsets.only(left: 13),
child: AspectRatio(
aspectRatio: 4 / 7,
child: CircleAvatar(
backgroundColor: AppColors.blueColor,
child: Text(
"2",
style: TextStyle(color: Colors.white),
),
),
),
),
const Padding(
padding: EdgeInsets.all(8.0),
child: Text(
"Betslip",
style: TextStyle(
fontWeight: FontWeight.bold, color: AppColors.blueColor),
),
),
Padding(
padding: EdgeInsets.only(left: 200.0),
child: GestureDetector(
child: const Text("Close", style: TextStyle(color: AppColors.blueColor),),onTap: (){},),
)
]),
),
]),
Container(
margin: const EdgeInsets.only(top: 50),
height: MediaQuery.of(context).size.height * 0.04,
width: MediaQuery.of(context).size.width,
decoration: BoxDecoration(
color: Colors.grey.shade300,
border: Border.all(width: .2, color: Colors.grey),
boxShadow: [
BoxShadow(
color: Colors.grey.withOpacity(0.5),
spreadRadius: 2,
blurRadius: 5,
offset: const Offset(0, 3), // changes position of shadow
),
],
),
child: Center(
child: TabBar(
onTap: (int index) {
setState(() {
_selectedIndex = index;
});
},
controller: _tabController,
tabs: myTabs,
isScrollable: true,
labelColor: AppColors.black,
unselectedLabelColor: AppColors.tabBarColorUnselected,
indicatorSize: TabBarIndicatorSize.tab,
indicatorColor: Colors.transparent,
),
),
),
SizedBox(height: 20,),
Padding(
padding: const EdgeInsets.only(right: 100.0),
child: TabBar(
onTap: (int index) {
setState(() {
_otherSelectedIndex = index;
});
},
controller: _secondTabbarController,
tabs: mySecondTabs,
isScrollable: true,
labelColor: AppColors.black,
unselectedLabelColor: AppColors.tabBarColorUnselected,
indicatorSize: TabBarIndicatorSize.tab,
indicatorColor: Colors.transparent,
),
),
///////// Tab Bar View
Expanded(
child: TabBarView(
controller: _tabController,
children: const [
BetSlipBottomSheet(),
BetSlipActive(),
BetSlipSettled(),
],
),
),
Expanded(
child: TabBarView(
controller: _secondTabbarController,
children: [
Text(""),
ParlayTabView(),
SizedBox(),
],
),
),
]),
),
);
}
}