Guest User

Untitled

a guest
Feb 18th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.85 KB | None | 0 0
  1. Widget build(BuildContext context) {
  2. final mBloc = BlocProvider.mReportsBloc(context);
  3. final fBloc = BlocProvider.fReportsBloc(context);
  4.  
  5. return DefaultTabController(
  6. length: 2,
  7. child: Scaffold(
  8. appBar: AppBar(
  9. elevation: 1.5,
  10. bottom: TabBar(
  11. tabs: [
  12. Container(
  13. child: textWrapper("M reports"),
  14. ),
  15. Container(
  16. child: textWrapper("F reports"),
  17. ),
  18. ],
  19. ),
  20. title: Text("Pool"),
  21. ),
  22. body: TabBarView(
  23. children: [
  24. buildMReportList(mBloc),
  25. buildFReportList(fBloc),
  26. ],
  27. ),
  28. ),
  29. );
  30. }
  31.  
  32.  
  33. Widget buildFReportList(ReportsBloc fBloc) {
  34. return StreamBuilder(
  35. stream: fBloc.fReports,
  36. builder: (context, AsyncSnapshot<List<ReportModel>> snapshot) {
  37.  
  38. if (!snapshot.hasData) {
  39. return Center(
  40. child: CircularProgressIndicator(),
  41. );
  42. }
  43. return ListView.builder(
  44. itemCount: snapshot.data.length,
  45. itemBuilder: (context, int index) {
  46. return _buildCard(snapshot.data[index], context);
  47. },
  48. );
  49. });
  50. }
  51.  
  52. Widget buildMReportList(ReportsBloc mBloc) {
  53. return StreamBuilder(
  54. stream: mBloc.mReports,
  55. builder: (context, AsyncSnapshot<List<ReportModel>> snapshot) {
  56.  
  57. if (!snapshot.hasData) {
  58. return Center(
  59. child: CircularProgressIndicator(),
  60. );
  61. }
  62. return ListView.builder(
  63. itemCount: snapshot.data.length,
  64. itemBuilder: (context, int index) {
  65. return _buildCard(snapshot.data[index], context);
  66. },
  67. );
  68. });
  69. }
Add Comment
Please, Sign In to add comment