Why my CustomScrollView is not scrollable?

0

I am beginner in Flutter, I have 4 Listviews having some conditions to be visible on screen and I am adding those in a CustomScrollView in SilverLists but due to some reason my screen is not scrollable. Here is my code:

Widget build(BuildContext context) {
    return Scaffold(
        key: _scaffoldKey,
        appBar: PreferredSize( //code for preferred size
        drawer: Drawer( //code for drawer

        body: Container(
          child: StreamBuilder<DocumentSnapshot>(
              stream: Firestore.instance
                  .collection('users')
                  .document(widget._user.uid)
                  .snapshots(),
              builder: (BuildContext context,
                  AsyncSnapshot<DocumentSnapshot> snapshot) {
                if (snapshot.hasError) {
                  return Text('Error : ${snapshot.error}');
                } else if (snapshot.hasData) {
                  List<bool> t = checksub(snapshot.data);
                  print(t.length);
                  print(t);
                  return showEvents(t);
                }
                return LinearProgressIndicator();
              }),
        ));
  }

  List<bool> checksub(DocumentSnapshot snapshot) {

    if (snapshot.data['t1'] == true) {
      arr[0] = true;
    } else
      arr[0] = false;

    if (snapshot.data['t2'] == true) {
      arr[1] = true;
    } else
      arr[1] = false;
    if (snapshot.data['t3'] == true) {
      arr[2] = true;
    } else
      arr[2] = false;
    if (snapshot.data['t4'] == true) {
      arr[3] = true;
    } else
      arr[3] = false;
    return arr;
  }

  Widget showEvents(List<bool> t) {
   
    return Container(
        child: CustomScrollView(
      scrollDirection: Axis.vertical,
      slivers: <Widget>[
        SliverList(
          delegate: SliverChildListDelegate(
            [if (t[0] == true) sss1()]
          ),
        ),
        SliverList(
          delegate: SliverChildListDelegate(
            [if (t[1] == true) sss2()],
          ),
        ),
        SliverList(
          delegate: SliverChildListDelegate(
            [if (t[2] == true) sss3()],
          ),
        ),
        SliverList(
          delegate: SliverChildListDelegate(
            [if (t[3] == true) sss4()],
          ),
        ),
      ],
    ));
  }

  Widget sss1(){
    return Container(
      child: StreamBuilder<QuerySnapshot>(
        stream: Firestore.instance
            .collection('notifications')
            .where('Category', isEqualTo: 't1')
            .orderBy('createdAt', descending: true)
            .snapshots(),
        builder: (BuildContext context, AsyncSnapshot<QuerySnapshot> snapshot) {
          if (snapshot.hasError) return Text('Error: ${snapshot.error}');
          switch (snapshot.connectionState) {
            case ConnectionState.waiting:
              return Text('Loading...');
            default:
              return Expanded(
                  child: ListView(
                shrinkWrap: true,
                children:
                    snapshot.data.documents.map((DocumentSnapshot document) {
                  return Card(
                    color: Color(0xffffffff),
                    child: CustomCard(
                      title: document['Title'],
                      description: document['Body'],
                      //topic: document['Topic'],
                      context: context,
                      isAdmin: false,
                      ndate: document['Date'],
                      stime: document['Time'],
                      url: document['URL'],
                      desc: document['Description'],
                    ),
                  );
                }).toList(),
              ));
          }
        },
      ),
    );
  }

sss2(),sss3(),sss4() are exact similar to Widget sss1() except for one condition in firestore.collection.

firebase
flutter
listview
asked on Stack Overflow Jun 25, 2020 by achal1304 • edited Jun 25, 2020 by Brian Tompsett - 汤莱恩

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0