i am trying to implement TabBarView in my app .
i have filter in my app and have placed tababr below that filter and want to place TabBarView below that tabbar but it seems something is wrong .
it is showing black screen if i don't wrap tabbar with scaffold and if i wrap with Scaffold it does not show tab screen here , below is the code
@override
void initState() {
super.initState();
initializeRawData();
tabController = TabController(length: 2, vsync: this);
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
actions: [
GestureDetector(
onTap: () => showChooser(),
child: Container(
padding: EdgeInsets.symmetric(horizontal: 10.0),
child: SvgPicture.asset(
"images/pdf.svg",
height: 24.0,
width: 24.0,
color: MyApplication().hexToColor(AppColors.white),
),
),
),
],
title: Text(
AppString.balancesheet_screen,
style: TextStyle(
fontWeight: FontWeight.bold,
),
),
elevation: 4.0,
flexibleSpace: Container(
decoration: BoxDecoration(
color: MyApplication().hexToColor(AppColors.toolbar),
),
),
),
body: Container(
decoration: BoxDecoration(
color: MyApplication().hexToColor(AppColors.off_white),
),
child: Column(
children: [
// filter heading
Container(
decoration: BoxDecoration(
color: MyApplication().hexToColor(AppColors.toolbar),
),
padding: EdgeInsets.symmetric(horizontal: 30.0, vertical: 16.0),
// to date filter part
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceAround,
children: [
// to date column
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"From Date",
style: TextStyle(
color: MyApplication().hexToColor(AppColors.white),
fontWeight: FontWeight.w100,
fontSize: 16.0,
),
),
SizedBox(height: 10.0),
GestureDetector(
onTap: () async {
String date = await showPickerDialogAndGetDate(
context,
AppString.PREF_BALANCE_SHEET_FROM_DATE);
setState(() {
widget.fromDate = date;
});
},
child: Container(
padding: EdgeInsets.symmetric(
horizontal: 8.0, vertical: 4.0),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(4.0),
color: MyApplication()
.hexToColor(AppColors.toobar_dark)),
// calendar , date
child: Row(
children: [
SvgPicture.asset(
"images/calendar.svg",
color: MyApplication()
.hexToColor(AppColors.white),
height: 24.0,
width: 24.0,
),
SizedBox(width: 4.0),
Text(
widget.fromDate,
style: TextStyle(
color: MyApplication()
.hexToColor(AppColors.white),
fontWeight: FontWeight.bold,
),
),
],
),
),
),
],
),
// to date column
Column(
crossAxisAlignment: CrossAxisAlignment.start,
children: [
Text(
"To Date",
style: TextStyle(
color: MyApplication().hexToColor(AppColors.white),
fontWeight: FontWeight.w100,
fontSize: 16.0,
),
),
SizedBox(height: 10.0),
GestureDetector(
onTap: () async {
String date = await showPickerDialogAndGetDate(
context, AppString.PREF_BALANCE_SHEET_TO_DATE);
setState(() {
widget.toDate = date;
});
},
child: Container(
padding: EdgeInsets.symmetric(
horizontal: 8.0, vertical: 4.0),
decoration: BoxDecoration(
borderRadius: BorderRadius.circular(4.0),
color: MyApplication()
.hexToColor(AppColors.toobar_dark)),
// calendar , date
child: Row(
children: [
SvgPicture.asset(
"images/calendar.svg",
color:
MyApplication().hexToColor(AppColors.white),
height: 24.0,
width: 24.0,
),
SizedBox(width: 4.0),
Text(
widget.toDate,
style: TextStyle(
color: MyApplication()
.hexToColor(AppColors.white),
fontWeight: FontWeight.bold,
),
),
],
),
),
),
],
), //
],
),
),
balanceSheetTabBar(),
],
),
),
);
}
void showChooser() {
showModalBottomSheet(
context: context,
builder: (BuildContext context) {
return PDFOptionBottomSheet(
onChoose: (String action) {
Toast.show(action, context);
},
);
});
}
Widget balanceSheetTabBar() {
return Container(
width: double.infinity,
height: 52.0,
child: DefaultTabController(
length: 2,
child: Scaffold(
appBar: AppBar(
backgroundColor: MyApplication().hexToColor(AppColors.white),
bottom: TabBar(
controller: tabController,
labelColor: MyApplication().hexToColor(AppColors.black),
indicator: UnderlineTabIndicator(
borderSide: BorderSide(
width: 3.0,
color: MyApplication().hexToColor(AppColors.toolbar)),
),
labelStyle: TextStyle(
fontWeight: FontWeight.bold,
color: MyApplication().hexToColor(AppColors.black),
fontSize: 18.0,
fontFamily: AppFontFamily.NormalTextFamily,
),
tabs: [
Tab(text: AppString.liablitites),
Tab(text: AppString.assests),
],
),
),
body: TabBarView(
controller: tabController,
children: [
Icon(Icons.ac_unit),
Icon(Icons.home)
],
),
),
),
);
}
Thank You .
question from:
https://stackoverflow.com/questions/65517074/tabbarview-not-showing-screens-flutter