0

I have two list view. One is a wrapper of all the widgets in the view, the second one is a child of it. Here is the code:

ListView(
                    scrollDirection: Axis.vertical,
                    physics: AlwaysScrollableScrollPhysics(),
                    children: [
                      Container(
                         ................
                          ),
                      Container(
                         ................
                      ),
                      ListView.builder(
                        itemBuilder: (context, index) {
                          return Expanded(child: Column(children: [
                            Divider(
                              color: Colors.black12,
                              height: 20,
                              thickness: 1,
                              indent: 20,
                              endIndent: 0,
                            ),
                            Row(children: [
                              Image.network(
                                  "http://openweathermap.org/img/wn/[email protected]"),
                              Text(Utils.days[index + 1],
                                  style: GoogleFonts.roboto(
                                      fontSize: 16, color: Colors.white))
                            ]),
                          ]));
                        },
                        itemCount: 5,
                        scrollDirection: Axis.vertical,
                      )
                    ]);

The two containers are visible. I can't see the items inside the second list view. There isn't any error in the console. I have no idea why is this happening.

2
  • do not nest two or more ListViews - instead use CustomScrollView Commented Dec 21, 2020 at 10:52
  • add shrinkWrap: true below second list view Commented Dec 21, 2020 at 11:36

2 Answers 2

1

I fixed it by adding shrinkWrap: true and physics: NeverScrollableScrollPhysics() to the nested ListView

Sign up to request clarification or add additional context in comments.

Comments

0

I Hope this code will work for you.

      return Scaffold(
      body: Container(
          child: SingleChildScrollView(
        child: Column(mainAxisSize: MainAxisSize.min,
            // scrollDirection: Axis.vertical,
            // physics: AlwaysScrollableScrollPhysics(),
            children: [
              Container(
                child: Text("one"),
              ),
              Container(
                child: Text("two"),
              ),
              Container(
                height: MediaQuery.of(context).size.height / 2,
                child: ListView.builder(
                  itemBuilder: (context, index) {
                    return Column(children: [
                      Divider(
                        color: Colors.black12,
                        height: 20,
                        thickness: 1,
                        indent: 20,
                        endIndent: 0,
                      ),
                      Row(children: [
                        Image.network(
                            "http://openweathermap.org/img/wn/[email protected]"),
                        Text(index.toString(),
                            style: GoogleFonts.roboto(
                                fontSize: 16, color: Colors.white))
                      ]),
                    ]);
                  },
                  itemCount: 5,
                  scrollDirection: Axis.vertical,
                ),
              )
            ]),
      )),
    );

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.