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.

Revisions

  1. D-sense created this gist Feb 16, 2019.
    69 changes: 69 additions & 0 deletions gistfile1.txt
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,69 @@
    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);
    },
    );
    });
    }