Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Flutter. SingleChildScrollView doesn't scroll into Positioned widget

I’m using flutter to create an app.
I’m trying to create a sort of box(using Positioned widget) where inside there will be a a scrollable list of widget.
I need a Positioned widget to put in the right postion of stack my "box" widget.
My problem is the list of object doesn’t scroll. Any suggestion?

Widget build(BuildContext context) {
    return FutureBuilder<List<SoccerMatch>>(
      future: SoccerApi().getAllMatches(),
      builder: (context, snapshot) {
        if (snapshot.hasData) {
          return Positioned(
            top: _queryData.size.height * 0.50,
            bottom: -_queryData.size.height * 0.6,
            right: _queryData.size.width * 0.1,
            left: _queryData.size.width * 0.1,
            child: SingleChildScrollView(
              physics: ScrollPhysics(),
              child:
              Column(
                children: [
                  ListView.builder(
                    scrollDirection: Axis.vertical,
                    physics: NeverScrollableScrollPhysics(),
                    shrinkWrap: true,
                    itemCount: snapshot.data!.length,
                    itemBuilder: (context, index)
                    {
                      return matchTile(snapshot.data![index]);
                    },
                  ),
                ],
              ),

            ),


          );
        } else {
          return Center(
            child: CircularProgressIndicator(),
          );
        }
      },
    );
  }

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Just try to update your FutureBuilder with the following

          FutureBuilder<List<SoccerMatch>>(
        future: SoccerApi().getAllMatches(),
        builder: (context, snapshot) {
          print(snapshot);
          if (!snapshot.hasData) {
            return Center(
              child: CircularProgressIndicator(),
            );
          }
          if (snapshot.hasData) {
            return Stack(
              children: [
                Positioned(
                  top: _queryData.size.height * 0.50,
                  bottom: -_queryData.size.height * 0.6,
                  right: _queryData.size.width * 0.1,
                  left: _queryData.size.width * 0.1,
                  child: SingleChildScrollView(
                      physics: ScrollPhysics(),
                      child:
                      Column(
                        children: (snapshot.data as List<SoccerMatch>).map((item) => matchTile(item)),
                      ).toList()),
                ),
              ],
            );
          }

          return SizedBox();
        }
      )
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading