Created
February 16, 2019 13:13
-
-
Save D-sense/b49f1399db40214b2e050a81291e890c to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Widget build(BuildContext context) { | |
final mBloc = BlocProvider.mReportsBloc(context); | |
final fBloc = BlocProvider.fReportsBloc(context); | |
return DefaultTabController( | |
length: 2, | |
child: Scaffold( | |
appBar: AppBar( | |
elevation: 1.5, | |
bottom: TabBar( | |
tabs: [ | |
Container( | |
child: textWrapper("M reports"), | |
), | |
Container( | |
child: textWrapper("F reports"), | |
), | |
], | |
), | |
title: Text("Pool"), | |
), | |
body: TabBarView( | |
children: [ | |
buildMReportList(mBloc), | |
buildFReportList(fBloc), | |
], | |
), | |
), | |
); | |
} | |
Widget buildFReportList(ReportsBloc fBloc) { | |
return StreamBuilder( | |
stream: fBloc.fReports, | |
builder: (context, AsyncSnapshot<List<ReportModel>> snapshot) { | |
if (!snapshot.hasData) { | |
return Center( | |
child: CircularProgressIndicator(), | |
); | |
} | |
return ListView.builder( | |
itemCount: snapshot.data.length, | |
itemBuilder: (context, int index) { | |
return _buildCard(snapshot.data[index], context); | |
}, | |
); | |
}); | |
} | |
Widget buildMReportList(ReportsBloc mBloc) { | |
return StreamBuilder( | |
stream: mBloc.mReports, | |
builder: (context, AsyncSnapshot<List<ReportModel>> snapshot) { | |
if (!snapshot.hasData) { | |
return Center( | |
child: CircularProgressIndicator(), | |
); | |
} | |
return ListView.builder( | |
itemCount: snapshot.data.length, | |
itemBuilder: (context, int index) { | |
return _buildCard(snapshot.data[index], context); | |
}, | |
); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment