Skip to content

Instantly share code, notes, and snippets.

@D-sense
Created February 16, 2019 13:13
Show Gist options
  • Save D-sense/b49f1399db40214b2e050a81291e890c to your computer and use it in GitHub Desktop.
Save D-sense/b49f1399db40214b2e050a81291e890c to your computer and use it in GitHub Desktop.
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